BuddyDev

Search

How to change the default loading order of a Buddypress Sub-Nav?

  • Participant
    Ian on #6712

    In my Buddypress site I have two profile field groups – ‘Base’ & ‘User Info’. (I need both in order to simplify the signup process for my users.)

    When a user wants to edit their profile, they select their ‘Profile’ from the Profile Nav Bar, then select ‘Edit’. This brings them, by default, to the ‘Base’ profile group, whose fields I have hidden, as I do not want them to be edited. In the same subnav as the ‘Base’ profile group is the ‘User Info’ profile group, which then needs to be selected in order to edit. I want to only display the ‘User Info’ group.

    Is there a way to make the ‘User Info’ profile group load by default, so I can then hide the ‘Base’ field group tab?

    I have uploaded a screenshot of the issue here:

    https://c2.staticflickr.com/6/5550/31483439525_e0e9f7ec8b.jpg

    The urls of the field groups are different (/profile/edit/group/1/ and /profile/edit/group/2/), so perhaps that could help with a solution?

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #6720

    Hi Ian,
    Welcome to BuddyDev.

    Please put this in your bp-custom.php

    
    /**
     * Set default redirect to profile group id of your choice on the Edit Profile
     *  instead of teh profile group 1 when someone opens members/name/profile/edit page
     *
     */
    function buddydev_custom_default_redirect_profile_group () {
    
    	if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) {
    		return false;
    	}
    
    	$profile_group_id = 2;//change it to whatever
    
    	// Make sure a group is set.
    	if ( ! bp_action_variable( 1 ) ) {
    		bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/'. $profile_group_id ) );
    	}
    }
    add_action( 'bp_screens', 'buddydev_custom_default_redirect_profile_group', 2 );
    
    

    You can change the profile_group_id to the id of the default group you want to be visible.

    Hope that helps.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved