Buddypress - Remove 'Delete Account' Link from Admin Bar Menu

I'm trying to remove the Buddypress 'Delete Account' link from the admin menu using the Branding CSS plugin. I can't figure out the CSS to use. I've attached an image. Help! :slight_smile:

  • James Morris

    Hello Chris,

    I hope you are well today.

    Actually, this can be accomplished with a setting in BuddyPress. If you go to Admin -> Settings -> BuddyPress -> Options, you can deselect the option Allow registered members to delete their own accounts.

    Another option is a little addition to your functions.php file. Using the get node() function, you can easily modify any Admin Toolbar link.

    The code you would need to use would be something like the following:

    add_action( 'admin_bar_menu', 'remove_delete_node', 999 );
    
    function remove_delete_node( $wp_admin_bar ) {
    
    	$bp_delet_node = $wp_admin_bar->get_node( 'my-account-settings-delete-account' );
    
    	// Check if the 'my-account-settings-delete-account' node exists
    	if( $bp_delet_node ) {
    		$wp_admin_bar->remove_node( 'my-account-settings-delete-account' );
    	}
    }

    You could also add this in a mu-plugin to ensure it works with all themes.

    Please see the following links for more information:
    https://codex.wordpress.org/Function_Reference/get_nodes
    https://codex.wordpress.org/Function_Reference/get_node

    I hope this clarifies a bit.

    Best regards,

    James Morris

  • Chris

    Hi James

    The code worked perfectly. I didn't want to disable deleting sites. However, I noticed that people who sign up to kick the tires will delete their accounts, but not their sites. This leaves empty/ugly looking sites in the directory. To counter this, I created a Delete Account page where a user must first delete his/her site. Once they click the 'Delete Site' link, another link appears using javascript to 'Delete Account'. The code above removes the Buddypress menu option for deleting an account, forcing users to select my Delete Account page.

    Thanks for your help!
    Chris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.