Skip to:
Content
Pages
Categories
Search
Top
Bottom

Disable Change Email Address?


  • yusareba
    Participant

    @yusareba

    In the settings (general) panel of buddypress, users can change their email address.

    How can I remove or disable this?

    If needed, I would be willing to use CSS but can’t find the identifier.

Viewing 25 replies - 1 through 25 (of 30 total)

  • Venutius
    Moderator

    @venutius

    Sounds like you need to remove the nav item that corresponds to that link.

    There’s two menu items that possibly need to be removed. the most common one could be removed with the bp_core_remove_subnav_item( 'settings', 'general' ); function.

    Do you also use the WordPress/BuddyPress adminbar?


    yusareba
    Participant

    @yusareba

    No, only the actual buddypress profile.


    Venutius
    Moderator

    @venutius

    So you could add something like the following to your functions or bp-custom.php:

    function venutius_hide_tab() {
    	if ( !is_super_admin() && !bp_is_my_profile() ) {
    		bp_core_remove_subnav_item( 'settings', 'general' ); 
    	}
    }
    add_action( 'bp_setup_nav', 'venutius_hide_tab', 15 );

    yusareba
    Participant

    @yusareba

    added, unfortunately there was no visible change (cleared cache ofc)


    Venutius
    Moderator

    @venutius

    it excludes admin users from the removal, so you will need to login as a standard user


    yusareba
    Participant

    @yusareba

    :^) i’ll check


    yusareba
    Participant

    @yusareba

    tested. sadly, didn’t work


    Venutius
    Moderator

    @venutius

    OK let me give it a test and get back to you


    yusareba
    Participant

    @yusareba

    Take your time. I’m very thankful to have some help


    Venutius
    Moderator

    @venutius

    Update – the following works:

    function venutius_hide_tab() {
    	if ( !is_super_admin() ) {
    		bp_core_remove_subnav_item( 'settings', 'general' ); 
    	}
    }
    add_action( 'bp_setup_nav', 'venutius_hide_tab', 15 );

    However it causes a page not found error when you click on Settings, this is due to the removed nav item being the default tab for the settings link. I’m currently trying to find the right code to reset this default.


    yusareba
    Participant

    @yusareba

    yep, I figured that would be a problem :’)

    it honestly blows my mind that nothing is generally available for wordpress to prevent users changing their email addresses. That seems pretty fundamental


    yusareba
    Participant

    @yusareba

    Sorry, I just got back to pc after sleep. I saw a reply but it’s not here. deleted?


    Venutius
    Moderator

    @venutius

    That’s wierd, I did post a reply, now it’s gone.

    Here it is again:

    function venutius_change_profile_settings_edit_tab() {
    
    	if( bp_is_active( 'xprofile' ) ) :
    
    	$access        = bp_core_can_edit_settings();
    	$slug          = bp_get_settings_slug();
    
    	$args = array(
    		'parent_slug'     => $slug,
    		'subnav_slug'	  => $slug . '/notifications/',
    		'screen_function' => 'bp_settings_screen_notification',
    		'user_has_access' => $access
    		);
     
    	bp_core_new_nav_default( $args );
    
    	bp_core_remove_subnav_item( 'settings', 'general' );
    
    	endif;
    
    }
    add_action( 'bp_actions', 'venutius_change_profile_settings_edit_tab' );

    yusareba
    Participant

    @yusareba

    that’s beautiful!!! now I just have to redirect /settings/ to /settings/notifications/

    can you add that line in it so it’s all in the same place? (so I don’t have to use plugin)

    I can’t believe how amazing this is working


    Venutius
    Moderator

    @venutius

    You mean something like this:

    function venutius_change_profile_settings_edit_tab() {
    
    	if( bp_is_active( 'xprofile' ) ) :
    
    	$access        = bp_core_can_edit_settings();
    	$slug          = bp_get_settings_slug();
    
    	$args = array(
    		'parent_slug'     => $slug,
    		'subnav_slug'	  => 'notifications',
    		'screen_function' => 'bp_settings_screen_notification',
    		'user_has_access' => $access
    		);
     
    	bp_core_new_nav_default( $args );
    
    	bp_core_remove_subnav_item( 'settings', 'general' );
    
    	endif;
    
    }
    add_action( 'bp_actions', 'venutius_change_profile_settings_edit_tab' );

    yusareba
    Participant

    @yusareba

    I actually fixed it. The previous code you said (before this one) was missing a ‘ before the slug notifications so It wasn’t going where it was supposed to. I added the ‘ and it’s working 100%.

    I’m so thankful that you took time out of your day to help me. I hope others benefit as well.


    yusareba
    Participant

    @yusareba

    I’m not sure if I should create a new thread for this or not, because it’s somewhat related.

    There’s a tab called “Email” in the settings. It’s URI is /members/*/settings/notifications/

    I would like to redirect it to just /members/*/settings/

    Is there something I can add to functions.php to do this?

    Again.. Thank you.


    Venutius
    Moderator

    @venutius

    So it sounds like you’d want to remove it from the nav, and set your default landing page to be just settings?


    yusareba
    Participant

    @yusareba

    I would like to change the link of the Email settings subnav to be the Settings main nav URL.

    There should be no removal of nav, just changing the url.

    from

    /members/*/settings/notifications/ (Email Settings) to

    /members/*/settings/ (Overall Settings)


    yusareba
    Participant

    @yusareba

    Let me know if it’s still confusing. I’m having a hard time phrasing it better


    Venutius
    Moderator

    @venutius

    my concern is that by doing that you risk hiding the email notifications page from your members inadvertently.


    yusareba
    Participant

    @yusareba

    It won’t because you helped me change ‘settings’ to the notifications settings page.

    /members/*/settings/ takes members to the notifications settings.

    It used to take members to change email address, but we changed it 🙂

    Not doing anything sketchy O:


    Venutius
    Moderator

    @venutius

    So you’d want to remove it then add it again with the new setting, do you still want to call it email?


    yusareba
    Participant

    @yusareba

    I would still call it email. I would just be redirecting it to /members/*/settings/

    There is no need to add or remove a tab.

    Technically, It would be going to the same place.

    /members/admin/settings/ and /members/admin/settings/notifications are the same endpoint atm.

    The reason why I want to do this is because of a problem with targeting its URL with a wildcard.

    The wildcard thinks I want to target:
    /members/*/notifications/
    instead of
    /members/*/settings/notifications/

    Because the * is assuming /settings/ is part of it.

    In any case, doing this should solve the issue


    Venutius
    Moderator

    @venutius

    From what I can see, /settings/ actually redirects to /settings/notifications if you redirect notifications to settings the page has nowhere to go and you get a page not found error.

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