BuddyDev

Search

[Resolved] Default Profile Screen

Tagged: 

  • Participant
    Level: Enlightened
    Posts: 29
    Lisa Lagrou on #39522

    How do you change the default profile screen to go to the Edit Profile when a user clicks on their own profile?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1796
    Ravi on #39535

    Hello Lisa,

    Please use the following code:

    
    /**
     * Override default nav profile.
     */
    function buddydev_set_profile_default_nav() {
    
    	if ( ! bp_is_my_profile() ) {
    		return;
    	}
    
    	add_filter( 'bp_do_redirect_canonical', '__return_false' );
    
    	bp_core_new_nav_default(
    		array(
    			'parent_slug'     => bp_get_profile_slug(),
    			'subnav_slug'     => 'edit',
    			'screen_function' => 'xprofile_screen_edit_profile',
    		)
    	);
    // Determine user to use.
    	if ( bp_displayed_user_domain() ) {
    		$user_domain = bp_displayed_user_domain();
    	} elseif ( bp_loggedin_user_domain() ) {
    		$user_domain = bp_loggedin_user_domain();
    	} else {
    		return;
    	}
    
    	$slug         = bp_get_profile_slug();
    	$profile_link = trailingslashit( $user_domain . $slug );
    
    	bp_core_new_subnav_item(
    		array(
    			'name'            => _x( 'View', 'Profile header sub menu', 'buddypress' ),
    			'slug'            => 'public',
    			'parent_url'      => $profile_link,
    			'parent_slug'     => bp_get_profile_slug(),
    			'screen_function' => function () {
    				xprofile_screen_display_profile();
    			},
    			'position'        => 10,
    		)
    	);
    }
    
    add_action( 'bp_setup_nav', 'buddydev_set_profile_default_nav', 20 );
    
    

    Please do let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 29
    Lisa Lagrou on #39542

    Works perfectly! Thank you!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1796
    Ravi on #39544

    Hello Lisa,

    Thank you for the acknowledgment. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Default Profile Screen’ is closed to new replies.

This topic is: resolved