wp-user-profiles icon indicating copy to clipboard operation
wp-user-profiles copied to clipboard

Documentation on how to remove the 'Other' Tab

Open baden03 opened this issue 1 year ago • 0 comments

In the past I have used the wp_user_profiles_core_files filter to basically rewrite the entire default sections like so:

add_filter( 'wp_user_profiles_core_files', 'my_custom_tabs', 10, 2 );
function my_custom_tabs($files, $sources){
		$path = plugin_dir_path( __FILE__ );
		$files[1] = $path . 'my_custom_user_profile_tabs.php'; // override the standard profile.php
		unset($files[7]); //all-status.php
		unset($files[20]); //profile-name.php
		unset($files[30]); //sections.php
		return $files;
	}

That was fine when I had to do some serious customisation. But now I only want to accomplish two things:

  1. remove the Other Tab (for editing one's own profile and others)
  2. Add my own fantastic custom tabs.

In crawling through the source code I run across the wp_user_profiles_show_other_section filter in sections.php, but it's not doing what you'd think it should, namely: show_other_section as in:

add_filter( 'wp_user_profiles_show_other_section', '__return_false');

So, what would be the recommended procedure for simply removing a single section like the catch-all 'other' tab? Once this is settled (or improved if needed) I will happily expand the README.md with some more detailed documentation and even an example or two under:

Can I add my own sections?

Yes. There are a filters you can use to add or remove sections and their metaboxes.

p.s. will also fix the typo in the above.

baden03 avatar Jun 14 '23 08:06 baden03