Wordpress - How to remove Biography from user profile admin page
There is no dedicated hook – user management is a low priority in WordPress. You have to use output buffering (yes, not nice).
Here is a simple demonstration how this could be done:
add_action( 'personal_options', array ( 'T5_Hide_Profile_Bio_Box', 'start' ) );
/**
* Captures the part with the biobox in an output buffer and removes it.
*
* @author Thomas Scholz, <[email protected]>
*
*/
class T5_Hide_Profile_Bio_Box
{
/**
* Called on 'personal_options'.
*
* @return void
*/
public static function start()
{
$action = ( IS_PROFILE_PAGE ? 'show' : 'edit' ) . '_user_profile';
add_action( $action, array ( __CLASS__, 'stop' ) );
ob_start();
}
/**
* Strips the bio box from the buffered content.
*
* @return void
*/
public static function stop()
{
$html = ob_get_contents();
ob_end_clean();
// remove the headline
$headline = __( IS_PROFILE_PAGE ? 'About Yourself' : 'About the user' );
$html = str_replace( '<h2>' . $headline . '</h2>', '', $html );
// remove the table row
$html = preg_replace( '~<tr>\s*<th><label for="description".*</tr>~imsUu', '', $html );
print $html;
}
}
You can download the code as a standalone plugin: Plugin Remove Bio Box.
Before
After
The password fields are now under Contact Info … if you don’t like that, add a headline in stop()
– and take care for I18n. ;)
Since the recent class change this works:
add_action( 'personal_options', array ( 'T5_Hide_Profile_Bio_Box', 'start' ) );
/**
* Captures the part with the biobox in an output buffer and removes it.
*
* @author Thomas Scholz, <[email protected]>
*
*/
class T5_Hide_Profile_Bio_Box
{
/**
* Called on 'personal_options'.
*
* @return void
*/
public static function start()
{
$action = ( IS_PROFILE_PAGE ? 'show' : 'edit' ) . '_user_profile';
add_action( $action, array ( __CLASS__, 'stop' ) );
ob_start();
}
/**
* Strips the bio box from the buffered content.
*
* @return void
*/
public static function stop()
{
$html = ob_get_contents();
ob_end_clean();
// remove the headline
$headline = __( IS_PROFILE_PAGE ? 'About Yourself' : 'About the user' );
$html = str_replace( '<h3>' . $headline . '</h3>', '', $html );
// remove the table row
$html = preg_replace( '~<tr class="user-description-wrap">\s*<th><label for="description".*</tr>~imsUu', '', $html );
print $html;
}
}
The simplest and most lightweight solution is to use CSS to just hide it from view.
.user-description-wrap {
display: none;
}