Just upgraded to WordPress 4.4 and I notice now my users’ profile page in admin, there’s a section called “profile picture”, with a link to Gravatar.

The plugin I’m developing restricts a lot of things in profile.php; unfortunately by deleting from the DOM via jQuery:

jQuery( document ).ready(function() {
    jQuery( "h2:contains('Personal Options')" ).remove();
    jQuery( "h2:contains('Name')" ).remove();
    jQuery( "h2:contains('Contact Info')" ).remove();
    jQuery( "h2:contains('About Yourself')" ).remove();
    jQuery( "h2:contains('Account Management')" ).remove();
    jQuery( "tr.show-admin-bar" ).parents("table:first").remove();
    jQuery( "tr.user-first-name-wrap" ).remove();
    jQuery( "tr.user-last-name-wrap" ).remove();
    jQuery( "tr.user-nickname-wrap" ).remove();
    jQuery( "tr.user-display-name-wrap" ).remove();
    jQuery( "tr.user-url-wrap" ).remove();
    jQuery( "tr.user-description-wrap").parents("table:first").remove();
    jQuery( ".user-sessions-wrap" ).remove();
});

Before I continue on the jQuery addiction, is there a better way to do this (aside from output buffer replacement)? Also, is there some other setting specifically for the user profile picture, or is this jQuery solution going to be the answer for now?

4 s
4

We can use the show_avatars option to remove the Profile Picture section.

  • We can visit /wp-admin/options.php to turn it off manually.

  • Or update it with:

    update_option( 'show_avatars', 0 );
    
  • Or modify it through a filter:

    add_filter( 'option_show_avatars', '__return_false' );
    
  • We could also restrict it to the profile.php page:

    add_action( 'load-profile.php', function()
    {
       add_filter( 'option_show_avatars', '__return_false' );
    } );
    

Leave a Reply

Your email address will not be published. Required fields are marked *