• Resolved Jason Wong

    (@eljkmw)


    I see that Super Socializer automatically adds a message box and meta boxes into the backend User Profile. I wish to remove the message box “Link your social account to login to your account at this website”, and “Super Socializer – Social Avatar” meta boxes for Administrator and Editor roles.

    Please advise on how this can be accomplished through the active theme’s functions.php. Thank you in advance.

    https://www.ads-software.com/plugins/super-socializer/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Jason Wong

    (@eljkmw)

    I looked through your plugin’s source code, and found that the function the_champ_account_linking() within helper.php inserts lines of html codes into the User Profile. It’ll initially check if the user is logged in, and other conditions. I’m surprise it doesn’t limit the insertion to certain user roles.

    Plugin Author Heateor Support

    (@heateor)

    I wish to remove the message box “Link your social account to login to your account at this website”, and “Super Socializer – Social Avatar” meta boxes for Administrator and Editor roles.

    Place following code in functions.php file:

    function heateor_ss_remove_social_account_linking() {
    	?>
    	<style type="text/css">
    	div.super-socializer-linking-container{
    		display: none;
    	}
    	</style>
    	<?php if ( current_user_can( 'manage_options' ) || current_user_can( 'publish_posts' ) || current_user_can( 'publish_pages' ) ) { ?>
    		<script type="text/javascript">
    		jQuery(function(){
    			var heateorSsAvatarOptionsTable = jQuery('#ss_small_avatar').parents('table');
    			if(heateorSsAvatarOptionsTable){
    				jQuery(heateorSsAvatarOptionsTable).prev().remove();
    				jQuery(heateorSsAvatarOptionsTable).remove();
    			}
    		});
    		</script>
    		<?php
    	}
    }
    add_action( 'admin_notices', 'heateor_ss_remove_social_account_linking' );

    I’m surprise it doesn’t limit the insertion to certain user roles.

    We will try to add an option for enabling it on basis of user roles, ASAP.

    Thread Starter Jason Wong

    (@eljkmw)

    Awesome! Many, many thanks. \(^_^)/

    Plugin Author Heateor Support

    (@heateor)

    You’re welcome ??

    Thread Starter Jason Wong

    (@eljkmw)

    I managed to simplify your code to the following:

    // Remove Social Account linking
    function ss_remove_social_account_linking() {
    	// Administrator, Editor and Author user roles
    	if( current_user_can( 'manage_options' ) || current_user_can( 'publish_pages' ) || current_user_can( 'publish_posts' ) ) {
    		remove_action( 'edit_user_profile', 'the_champ_show_avatar_option' );
    		remove_action( 'show_user_profile', 'the_champ_show_avatar_option' );
    	}
    }
    add_action( 'admin_init', 'ss_remove_social_account_linking' );

    It works, and doesn’t require any jQuery …

    Update: That’s weird. It seems to have removed the_champ_show_avatar_option completely for all roles. Where did I go wrong?

    Thread Starter Jason Wong

    (@eljkmw)

    @team Heateor,

    After several unsuccessful attempts with other snippets, it seems that I’ve no other choice but to revert back to your snippet. Sigh …

    (><)”

    Plugin Author Heateor Support

    (@heateor)

    We had tried that code before and that didn’t work. That’s why we posted the alternative solution.

    Thread Starter Jason Wong

    (@eljkmw)

    @team Heateor,

    It’s so strange that you’ve tried my snippet before. But I’m curious why it didn’t work since your plugin has used an add_action function to hook the_champ_show_avatar_option to both edit_user_profile and show_user_profile. The remove_action function does unhook them. So, by right, it should work …

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to remove meta boxes from User Profile?’ is closed to new replies.