Skip to:
Content
Pages
Categories
Search
Top
Bottom

How To Change PERMALINK?


  • tazogamer
    Participant

    @tazogamer

    Hello.
    How to change user’s permalinks (profile page urls), from nicename to ID’s:
    mysite.com/forums/user/Mike-jovanr

    to

    mysite.com/forums/user/99

    ???

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

  • Robin W
    Moderator

    @robin-w

    It’s do-able undoubtably, but not sure how much code you’d need to change.

    Why are you wishing to do this?


    tazogamer
    Participant

    @tazogamer

    I WANT IT.
    HOW TO DO THAT?


    Robin W
    Moderator

    @robin-w

    you don’t actually need to change the permalinks eg is Kazza were user 15

    http://www.mysite.com/forums/users/15/edit/

    works just as well as

    http://www.mysite.com/fourms/users/kazza/edit

    so you’d need to change how the profile page is called so that it displays the no. in the url.

    Given that profile is called from

    any topic or reply display (click the avatar or author name)
    several widgets (click the avatar or author name)
    possibly other areas

    you’d need to re-code these areas.

    the function bbp_reply_author_link is used for topic and reply display, not sure if widgets use that as well.


    tazogamer
    Participant

    @tazogamer

    Robin W! Thanks so much! Your answers led me to the solution:
    in functions.php , i have added(with add_filter) a modified “bbp_get_user_profile_url” function,which generates profile urls (original is in bbpress\includes\users\template.php):

    here is my code:

    remove_filter( 'bbp_get_user_profile_url', 'bbp_get_user_profile_url');
    add_filter('bbp_get_user_profile_url','my_replaced' , 10 ,4);	
    function my_replaced ($url, $user_id, $user_nicename = '' ){
    	global $wp_rewrite;
    	if ( empty( $user_id ) ) {return false;}
    	$early_profile_url = apply_filters( 'bbp_pre_get_user_profile_url', (int) $user_id );
    	if ( is_string( $early_profile_url ) ) {   return $early_profile_url; }
    	if ( $wp_rewrite->using_permalinks() ) { 	// if pretty permalinks
    		$url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%';
    		if ( empty( $user_nicename ) ) { $user_nicename = bbp_get_user_nicename( $user_id );}
    
    		$url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_id, $url );
    		$url = home_url( user_trailingslashit( $url ) );
    
    	} 
    	else { 	// Unpretty permalinks
    		$url = add_query_arg( array( bbp_get_user_rewrite_id() => $user_id ), home_url( '/' ) );
    	}
    	//return apply_filters( 'Replaced_bbp_get_user_profile_url', $url, $user_id, $user_nicename );
    	return $url;
    }	

    Robin W
    Moderator

    @robin-w

    Hey great, glad you’re fixed !


    ikhaismail
    Participant

    @ikhaismail

    Hi @tazogamer. I tried your code to change user’s permalinks from nicename to ID’s. Yeah, the permalinks is changed, but the page its redirect is not found. Do you have any idea about this?


    itbuero
    Participant

    @itbuero

    I have the same issue. Can somewone please support me? Need to change the url from

    http://www.mysite.com/fourms/users/john

    to

    http://www.mysite.com/users/john

    thousand thanks!

    Peter


    Robin W
    Moderator

    @robin-w

    @itbuero

    dashboard>settings>forums>forum root slug and change ‘Prefix all forum content with the Forum Root slug’ to untick this

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar