ControlledChaos
4/5/2016 - 11:25 PM

Remove the "About User/About Yourself" section from the WordPress profile page.

Remove the "About User/About Yourself" section from the WordPress profile page.

<?php

add_action( 'personal_options', array ( 'hide_user_bio', 'start' ) );
/**
 * Captures the part with the biobox in an output buffer and removes it.
 */
class hide_user_bio
{
    /**
     * 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 class="user-description-wrap">\s*<th><label for="description".*</tr>~imsUu', '', $html );
        print $html;
    }
}

?>

Remove About User/About Yourself

WordPress Snippet