i have created widgets based on the profile types of users. in the init() method of my plugin i register the widgets with


now, i want each time a new user is created to unregister/deactivate the widgets which do not fit for this users profile. unfortunately the method elgg_unregister_widget_type() returns true (so the widget should be unregistered) but the widgets are still there.

what am i doing wrong? how to get rid of some widgets after a user has created a new profile?

  • just if somebody runs into the same problem - i figured out this solution:

    in the /views/default/object/widget.php just put the elgg_view_module() function that renders the widget in a IF clause that checks for the logged-in-users profile type:

    if ($profile_type->getTitle() !== elgg_echo('widgets:humans')) 
             echo elgg_view_module('widget', '', $widget_body, 
                             array('class' => $widget_class,
                                   'id' => $widget_id,'header' => $widget_header,));
  • Check the profile types of the users when registering the widgets and don't register them in the first place if they don't match the profile type. Though I'm not sure if you might ask for problems if the available widgets depend on something that can change for the users at a later time as they might not like it when widgets are no longer available they have gotten used to.

    [edit: I guess I was too late]

  • yep - a user should be able to change the profile type anytime. so the solution to "show/hide" the corresponding widgets when the profile type is changed seems more suitable.

    thx for your fast reply anyway!