WordPress.org

Support

Support » How-To and Troubleshooting » Remove some profile fields

Remove some profile fields

Viewing 15 replies - 1 through 15 (of 24 total)
  • Hi, if anyone has written a plugin to hide these fields, I’d love to hear about it too as I always have to remove them manually which is a bit of a pain when it comes to upgrading!

    Kind regards
    Croila

    In the end I used CYC and editted their custom profile file.

    The only way I’ve found is to use jQuery. I’m adding some custom fields using the edit_user_profile hook. So, at the start of the code that my function drops in at the end, I include something like this. I’m not using the jQuery( document ).ready method so the code runs asap.

    <script type="text/javascript">/* <![CDATA[ */
    var hideFields = [ "aim", "yim", "jabber" ];
    jQuery.each( jQuery( "form#your-profile tr" ), function() {
    	var field = jQuery( this ).find( "input,textarea,select" ).attr( "id" );
    	if ( hideFields.indexOf( field ) != -1 ) {
    		jQuery( this ).remove();
    	}
    });
    /* ]]> */</script>

    I’m doing other stuff, like slipping custom fields between built-in fields, but this is the basic method. Also, having the script inline means you can conditional write JS with PHP.

    Sorry for anyone not writing plugins or developing themes – I’ve not wrapped any of this up into a plugin, it’s just for functions.php in a custom theme.

    Tried this but it is not working for some reason.

    Using WP 2.9 and JQuery 1.3.2

    For WP 2.9.1, you can add the following PHP code to your “functions.php” file in your active theme directory:

    function add_twitter_contactmethod( $contactmethods ) {
      unset($contactmethods['aim']);
      unset($contactmethods['jabber']);
      unset($contactmethods['yim']);
      return $contactmethods;
    }
    add_filter('user_contactmethods','add_twitter_contactmethod',10,1);

    Works like a charm… and actually removes the fields instead of just “hiding” them using javascript.

    Hope that helps? 😉

    Wow! Thanks! That is definitely way better. I’ll try this instead.

    I couldn’t get e-sushi’s code to work at first, then I realized it was because I was using an old WP install. Once I upgraded it hid those fields like a charm.

    So, thanks!

    I don’t get the reference to adding twitter in the function name though. It didn’t do that and to my eye there doesn’t seem to be anything that would do it in this function. Am I missing something?

    e-sushi, thank you SO much for posting this code! It worked beautifully for me.

    However, I’d also like to strip out the “Website” form box and the entire “About Yourself” section with the biographical info box. I added into two extra lines of code into your function:

    unset($contactmethods['url']);

    and

    unset($contactmethods['description']);

    However, it’s not done anything. I have no idea how to remove these two items … Can anyone help, please?

    Many thanks!
    Croila

    Any update on this? I have the same problem… Thanks for all the help btw 🙂

    The “unset” I showed you above will only work for those 3 contact methods. For the other stuff, you need other code… not nice, but that’s WordPress.

    So, to dive in deeper: if you want to get rid of the “color options” at the top of the profile… simply use

    add_action('admin_head', 'admin_del_color_options'));
    
    function admin_del_options() {
       global $_wp_admin_css_colors;
       $_wp_admin_css_colors = 0;
    }

    This overrides the number of found color schemes to 0, preventing WordPress from rendering that “choose your color theme” thingy.

    Hope you’re starting to love me? 😉

    public function add_extra_contactmethod( $contactmethods ) {
        // Add new ones
        $contactmethods['twitter'] = 'Twitter';
        $contactmethods['identica'] = 'Identi.ca';
        $contactmethods['facebook'] = 'Facebook';
        $contactmethods['netlog'] = 'Netlog';
    
        // remove unwanted
        unset($contactmethods['aim']);
        unset($contactmethods['jabber']);
        unset($contactmethods['yim']);
    
        return $contactmethods;
    }

    Thanks e-sushi, just what I was looking for. Hope you don’t mind but I have corrected your 2nd code fragment for anyone who wan’t to cut ‘n’ paste.

    function admin_del_options() {
       global $_wp_admin_css_colors;
       $_wp_admin_css_colors = 0;
    }
    
    add_action('admin_head', 'admin_del_options');

    Hi,
    I have a similar problem.

    I need to remove “Website url” from the profile field, because I don’t want external links in profile.

    How can I do this? Thank you.

    In reply to my previous post, for the moment, I’ve opened /public_html/wp-admin/user-edit.php and deleted the following code.

    <tr>
    	<th><label for="url"><?php _e('Website') ?></label></th>
    	<td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
    </tr>

    Is there a better way to do this without hardcoding?

    Thanks

    Just wanted to say that e-sushi’s first piece of code worked for me on an install of 3.0 beta running in multisite mode + the latest version of Buddypress! I needed members to be able to add blog posts, but needed to do away with a lot of the admin panel profile fields so as not to confuse anyone.

    Thanks!

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Remove some profile fields’ is closed to new replies.
Skip to toolbar