WordPress.org

Ready to get started?Download WordPress

Forums

Remove some profile fields (25 posts)

  1. serpico
    Member
    Posted 4 years ago #

    Hi All

    I am using the Customize Your Community WordPress Plugin, to allow users to register, login and edit their profile. However, I do not want the following fields on the User profile. Can anyone recommend a way to remove them without having to lose the modification on upgrade.

    The fields I want to remove are:

    * Website
    * AIM
    * Yahoo IM
    * Jabber/ Google Talk
    * Biographical Info

    Thanks in advance!

  2. croila
    Member
    Posted 4 years ago #

    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

  3. serpico
    Member
    Posted 4 years ago #

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

  4. Steve Taylor
    Member
    Posted 4 years ago #

    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.

  5. Erum
    Member
    Posted 4 years ago #

    Tried this but it is not working for some reason.

    Using WP 2.9 and JQuery 1.3.2

  6. e-sushi
    Member
    Posted 4 years ago #

    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? ;)

  7. Erum
    Member
    Posted 4 years ago #

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

  8. Tzaddi
    Member
    Posted 4 years ago #

    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?

  9. croila
    Member
    Posted 4 years ago #

    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

  10. BinaryHotel
    Member
    Posted 4 years ago #

    Any update on this? I have the same problem... Thanks for all the help btw :)

  11. e-sushi
    Member
    Posted 4 years ago #

    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? ;)

  12. Lopo Lencastre de Almeida
    Member
    Posted 3 years ago #

    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;
    }
  13. zzfozz
    Member
    Posted 3 years ago #

    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');
  14. Zenigata
    Member
    Posted 3 years ago #

    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.

  15. Zenigata
    Member
    Posted 3 years ago #

    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

  16. justbishop
    Member
    Posted 3 years ago #

    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!

  17. lamarant
    Member
    Posted 3 years ago #

    I used this jQuery code in my main header to hide the bio:

    $('textarea#description').parent().parent().hide();
  18. geezerd
    Member
    Posted 3 years ago #

    This is the only code I found that worked with the 3.0 RC:

    function extended_contact_info($user_contactmethods) {  
    
    $user_contactmethods = array(
    'building' => __('Building'),
    'room' => __('Room'),
    'phone' => __('Phone')
    );  
    
    return $user_contactmethods;
    }  
    
    add_filter('user_contactmethods', 'extended_contact_info');

    I found it while web searching, forgot what site, sorry.
    It takes out all the others and puts in what ever you want. You can add as many on there as you need, like
    'shoesize' => __('Shoe Size')

  19. geezerd
    Member
    Posted 3 years ago #

    Sorry, I should be more specific:
    It removes the AIM, Yahoo IM, and Jabber / Google Talk fields.

    Oh. and a moment to vent...
    WHY are those 3 on there, but not Twitter? or Facebook? or LinkedIn?
    C'mon....

  20. zatuna
    Member
    Posted 3 years ago #

    Thanks for the coding geezerd, and point made!!

  21. zatuna
    Member
    Posted 3 years ago #

    Thanks for the coding geezerd, and point made!!

  22. e-sushi
    Member
    Posted 3 years ago #

    @geezerd and @zatuna: what the hell are you talking about? The toppic was "how to remove" and not "how to add" profile fields.

    It would've been cooler if you'ld contributed something that hasn't been posted in this thread before. Simply let me point you to @ipublicis contribution. @geezerd did nothing new.

    So much for my 2 cents...

  23. geezerd
    Member
    Posted 3 years ago #

    I can see your point, I got a bit off subject, but since ipublicus' code doesn't work in 3.0, I offered the only thing I found that worked.
    Simply leave the array empty if you want to just remove and not add:

    function extended_contact_info($user_contactmethods) {  
    
    $user_contactmethods = array();  
    
    return $user_contactmethods;
    }  
    
    add_filter('user_contactmethods', 'extended_contact_info');

    And, no "I" did nothing new, since I stated I found the code while web searching.

    So now you know what 2 cents is worth. Not much.

  24. taebp
    Member
    Posted 3 years ago #

    Hi Geezerd - I want to remove that garbage so bad and when I found this post I thought I was home free but alas, the garbage remains. I'm on 3.0 and here's what I added to functions.php and the outcome:

    I added (to the very end - obviously before the ?> ) the following:

    function extended_contact_info($user_contactmethods) {
    $user_contactmethods = array();
    return $user_contactmethods;
    }
    add_filter('user_contactmethods', 'extended_contact_info');

    This killed my site dead. I then removed just the last line:

    add_filter('user_contactmethods', 'extended_contact_info');

    and my site worked fine but the garbage (jabber bio yahoo, etc) was all still there.

    So I'm back to square one. I can list my plugins, etc but on the surface is there anything that jumps out that I may need to address?

    Thanks!

  25. geezerd
    Member
    Posted 3 years ago #

    Hmm... I dunno what to tell you, I just tried it on 3 different sites, it worked fine on all.

    It doesn't remove:
    Email
    Website
    About Yourself (Biographical Info)

    Those are still showing. Sites all up and crankin'.

    I myself would also like to know how to add new uneditable/non editable fields. Ones that subscribers can't change, but can see.

Topic Closed

This topic has been closed to new replies.

About this Topic