Support » Fixing WordPress » Remove the “bio” section from user profile?

  • Resolved glebec

    (@glebec)


    Hello,

    I’m using a plugin (Cimy Extra User Fields) to customize my users’ profile pages, and don’t want the standard WordPress user bio section to appear in the profile edit screen. After combing through the codex, I *think* I understand that this can be done by adding some code to my functions.php file (I do NOT want to modify the core files directly, not when it can be done via a plugin or functions.php). Specifically, I was thinking off using an action or filter hook to remove the following section from wp-admin/user-edit.php:

    <h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
    
    <table class="form-table">
    <tr>
    	<th><label for="description"><?php _e('Biographical Info'); ?></label></th>
    	<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br />
    	<span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
    </tr>

    However, this is where my php/WP coding skill ends. I can’t quite seem to be able to figure out how to actually accomplish this theoretical filter. Can someone point me in the right direction? Or if it’s not too much trouble, actually give a sample function that will filter this content?

    Thanks in advance,
    -GL

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter glebec

    (@glebec)

    FYI I’m working on this by attaching some php output buffering code to the admin_head and admin_footer action hooks. I’m then trying to filter the buffer using regular expressions. This seems like a relatively hardcore method however, plus I only just started experimenting with regex so it’s a bit tricky. I welcome any input.

    Thread Starter glebec

    (@glebec)

    SUCCESS! Had to buckle down and learn the basics of regular expressions, but here was my solution. Add this to your functions.php:

    <?php
    	// Callback function to remove default bio field from user profile page
    	function remove_plain_bio($buffer) {
    		$titles = array('#<h3>About Yourself</h3>#','#<h3>About the user</h3>#');
    		$buffer=preg_replace($titles,'<h3>Password</h3>',$buffer,1);
    		$biotable='#<h3>Password</h3>.+?<table.+?/tr>#s';
    		$buffer=preg_replace($biotable,'<h3>Password</h3> <table class="form-table">',$buffer,1);
    		return $buffer;
    	}
    
    	function profile_admin_buffer_start() { ob_start("remove_plain_bio"); }
    
    	function profile_admin_buffer_end() { ob_end_flush(); }
    
    	add_action('admin_head', 'profile_admin_buffer_start');
    	add_action('admin_footer', 'profile_admin_buffer_end');
    ?>

    This is a very iron-fisted method of admin page editing, however, and is strongly dependent on future WP updates not changing the format or text of the user admin page. So it’s really an ugly hack if there ever was one. But it should be very easy to update if you know (or can give yourself a crash course in) regular expressions.

    Hope this helps someone else,
    -GL

    I’ve posted a jQuery hack over here.

    @glebec: I love your sollution! Much better than those jquery “hiding” stuff. Tnx… 8]

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove the “bio” section from user profile?’ is closed to new replies.