Sociality (@sociality)

Forum Replies Created

Viewing 1 replies (of 1 total)

  • Sociality
    Participant

    @sociality

    Hi there I had the same problem and I used this solution that does not use buddypress. The sanitize title I use if for greek so I do not post it here but you should use something for sure.

    //This is used to hide the username from the profile url
    function tpp_forum_profile_url( $user_id, $old_values) {
    	$user = get_user_by( 'ID', $user_id );	
    		$display_name = $user->data->display_name;	
    	if ( $user ) {
    		if ( $user->data->user_status == 0 && $display_name ) {
    			$new_user_nicename = tpp_sanitize_title($display_name );
    			if ( strlen ( $new_user_nicename ) > 50 ) {
    				$new_user_nicename = substr ( $new_user_nicename, 0, 50 );
    			}				
    			if ( $user->data->user_nicename != $new_user_nicename ) { 
    				$args = array(
    					'ID'            => $user->ID,
    					'user_nicename' => $new_user_nicename
    				);
    				wp_update_user( $args );
    				wp_redirect( get_site_url().'/forums/user/'.$new_user_nicename.'/edit/' ); 
    				exit;					
    			}
    		}
    	}
    }
    add_action( 'profile_update',  'tpp_forum_profile_url', 100, 5 );
Viewing 1 replies (of 1 total)