• I’m looking for a way to make the profiles page less cluttered for non-admin users. For instance, they don’t need the instant messaging info or the bio field. I would like to remove them.

    Is there a plugin which does this?
    Or is there a way to do it without hacking the files in wp-admin/?

Viewing 5 replies - 1 through 5 (of 5 total)
  • One filter, a little jQuery..

    <?php
    /*
    Plugin Name: Hide profile stuff
    */
    add_filter( 'user_contactmethods' , 'contact_methods_filter' );
    add_action( 'admin_head-profile.php' , 'hide_bio_stuff' );
    
    function contact_methods_filter( $contact_methods ) {
    	if( !current_user_can( 'manage_options' ) )
    		return '';
    	return $contact_methods;
    }
    function hide_bio_stuff() {
    	if( !current_user_can( 'manage_options' ) ) :
    	?>
    		<script type="text/javascript">
    		//<![CDATA[
    			jQuery(document).ready( function($) {
    				var find_last_h3 = $('#your-profile').children('h3').length - 1;
    				//$('#your-profile h3').eq( find_last_h3 ).addClass('marker').hide();
    				$('#your-profile h3').eq( find_last_h3 ).addClass('marker').html('Password');
    				$('h3.marker + table tr:first-child').hide();
    			});
    		//]]>
    		</script>
    	<?php
    	endif;
    }

    Admin users won’t notice anything different, so if testing the code, just be sure you do it from a non-admin account… ??

    Plonk the code in a file with a php extension, upload it to your plugin folder, then activate it like you would any other plugin.

    Hope that helps..

    Thread Starter bootsmaat

    (@bootsmaat)

    Thank you, t31os_! This looks very promising. Actually, the elements are now hidden.

    But: I get two php errors

    Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/schlueter_1/wp-admin/includes/user.php on line 369

    Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/schlueter_1/wp-admin/user-edit.php on line 271

    Also, can you explain the jquery magic a bit so that I know how to customize it? For example I might want to hide additional elements.

    var find_last_h3 = $('#your-profile').children('h3').length - 1;

    Finds all the child H3 elements inside the form (which has the your-profile ID) and counts them.

    $('#your-profile h3').eq( find_last_h3 ).addClass('marker').html('Password');

    Adds a class to the last H3 and changes the text (About yourself isn’t appropriate when it’s only showing a password field – so i changed it simply for Password).

    $('h3.marker + table tr:first-child').hide();

    Finds that H3 by the class, looks for the table that follows and hides the first row.

    Regarding the error, i know what that is, change this..

    function contact_methods_filter( $contact_methods ) {
    	if( !current_user_can( 'manage_options' ) )
    		return '';
    	return $contact_methods;
    }

    ..to..

    function contact_methods_filter( $contact_methods ) {
    	if( !current_user_can( 'manage_options' ) )
    		return array();
    	return $contact_methods;
    }

    There’s an expectation in user-edit to receive an array, i hadn’t noticed as i initially tested under 3.0, where this error doesn’t appear, verified under 2.9 though, and now fixed with the above change.. ??

    The user profile page does not use any IDs throughout the various tables or headings, else the jQuery could have been a little more specific, the chosen method should be fine even if plugins are modifying that page via hooks (i don’t know for sure, but it was taken into consideration when writing the jQuery).

    Thread Starter bootsmaat

    (@bootsmaat)

    Thank you, t31os_! It’s working.

    You’re welcome… ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Less options on profiles page’ is closed to new replies.