Skip to:
Content
Pages
Categories
Search
Top
Bottom

MODIFY: Topic/Reply Author’s Profile Link


  • Spudnic
    Participant

    @spudnic072

    Is it possible to change where the link to the topic / reply’s author links to ?

    Currently when you click on the author’s name it links to the author’s bbPress profile, i would like it to link to my themes author.php file.

    Thanks for any replies.

Viewing 10 replies - 1 through 10 (of 10 total)

  • Spudnic
    Participant

    @spudnic072

    I have seen some discussion on this, but in the thread they talk about editing the post.php file, but i dont see how that would effect bbPress, and those topics are from around 3 years ago.

    You can use the bbp_get_user_profile_url filter. Something like:

     

    
    add_filter( 'bbp_get_user_profile_url', 'my_custom_author_link' );
    function my_custom_author_link( $user_id ){
        return get_author_link(false, $user_id);
    }
    

    (Not tested, but should help you get on track)


    Spudnic
    Participant

    @spudnic072

    I Tried:

    add_filter( 'bbp_get_user_profile_url', 'my_custom_author_link' );
    function my_custom_author_link( $user_id ){
        return get_author_posts_url(false, $user_id);
    }

    get_author_link(); appears to have been depreciated.

    So using:

    add_filter( 'bbp_get_user_profile_url', 'my_custom_author_link' );
    function my_custom_author_link( $user_id ){
    return get_author_posts_url( $user_id, false );
    }

    I am able to get to:

    http://localhost/wordpress/author/

    which is sooo close to what i need.

    I need it to return http://localhost/wordpress/author/$user_name


    Spudnic
    Participant

    @spudnic072

    add_filter( 'bbp_get_user_profile_url', 'my_custom_author_link' );
    function my_custom_author_link( $user_id ){
    $author_info = get_userdata( 1 );
    $author_name = $author_info->user_nicename; 
    return get_author_posts_url( false, $author_name );
    }

    is working properly.

    but when i change the input of
    $author_info = get_userdata( 1 );
    to
    $author_info = get_userdata( $user_id );

    I get:

    Notice: Trying to get property of non-object in C:\xampp\htdocs\wordpress\wp-content\themes\WoW_Public_Vent_Theme\functions.php on line 274

    and it does not work :(;

    Soo close.

    You’re sending false instead of empty. Try this:

    
    add_filter( 'bbp_get_user_profile_url', 'my_custom_author_link' );
    function my_custom_author_link( $user_id ){
      return get_author_posts_url( $user_id, '' );
    }
    

    Spudnic
    Participant

    @spudnic072

    That got me to:

    http://localhost/wordpress/author/

    Still missing the user name at the end of the url

    My bad, sorry. Wrong filter.

    Do this:

    
    add_filter( 'bbp_pre_get_user_profile_url', 'my_custom_author_link' );
    function my_custom_author_link( $user_id ) {
    	return get_author_posts_url( $user_id, '' );
    }
    

    Spudnic
    Participant

    @spudnic072

    Your the man. Works beautifully.

    Surprised this isn’t standard option ive seen alot of questions on it.

    If i continue to use bbPress i might make alittle “customization” faq and will def include this.

    Thanks again you’ve been supremely helpful.


    ryan360
    Participant

    @ryan360

    Bump. I just copied that function into my functions.php file and it’s still linking to the default bbPress forum user page.


    ryan360
    Participant

    @ryan360

    My hack job solution was to just modify the plugin itself. Line 356 in template.php contains the permalink structure which you can modify to suit your needs.

    	// Pretty permalinks
    		if ( $wp_rewrite->using_permalinks() ) {
    			$url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%';
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘MODIFY: Topic/Reply Author’s Profile Link’ is closed to new replies.
Skip to toolbar