How to unregister Avatars Widget?

Hello,

I like the plugin but don't want my users to have access to the Avatars Widget. I know there's plugins that allow you to hide widgets but in my case I need to go beyond hiding it and unregister it. I found the code that does this but for some reason it's not affecting this plugin. Any idea on how to unregister this one?

I tried putting this in my child-theme function.php file:

function unregister_specific_widgets() {
	unregister_widget('WA_Widget_Avatars');
add_action('widgets_init', 'unregister_specific_widgets', 1);
  • James Morris
    • WordPress Enthusiast

    Hello Robert,

    I hope you are well today.

    By the looks of your code, the add_action is inside the function. It should be after the function closes. Could you try the following and see if it works for you?

    function unregister_specific_widgets() {
    	unregister_widget('WA_Widget_Avatars');
    }
    add_action( 'widgets_init', 'unregister_specific_widgets' );

    Best regards,

    James Morris

  • Robert
    • The Incredible Code Injector

    Hi James, that was a typo :slight_frown:

    I should have put exactly what you types:

    function unregister_specific_widgets() {
    	unregister_widget('WA_Widget_Avatars');
             }
    add_action('widgets_init', 'unregister_specific_widgets', 1);

    I was actually able to use this code to remove default WP widgets, just not this one or other WPMUDEV widgets for that matter.

    I'm guessing WPMUDEV widgets are inserted somehow else, just not sure how.

  • Luís
    • Support

    Hi Robert ,

    Hope you're doing well today!

    From what I tested in my install, I think there is something to do with "priority" (1) given in the "add_action", that is not working. It worked well, without that parameter, as my teammate James suggested:

    function unregister_specific_widgets() {
    	unregister_widget('WA_Widget_Avatars');
             }
    add_action('widgets_init', 'unregister_specific_widgets');

    Cheers, Luís

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.