Add default widget for existing users?

At our site we want to enable the 'thewire' plugin, and add a 'thewire' widget to profiles.

Now, I can do that with the 'default widget' plugin. However, that appears to work for NEW users only.

Is there a chance to display default widgets for existing users too?


  • Not with the standard default widget plugin.  As you say, that only works for new users.

    Rewriting the widgets of existing users (who may have set their own preferences) could get messy.

    I once did a widget reset for a client that looked like this, but it basically assumed that users had no widgets. If you run this, back up your database first as there are no guarantees!

    $users = get_entities('user','',0,'',10000);

    $widget_layout = <<<END

    $widget_defs = explode("\n",$widget_layout);

    foreach ($widget_defs as $wd) {
        $wf = explode(":",$wd);
        $handle = $wf[0];
        $column = (int) $wf[1];
        $order = (int) $wf[2];
        foreach ($users as $user) {

  • Thanks for this, Kevin,

    going to discuss this with the team.

  • We have the new requirement:

    "I want default widgets on all user profiles or dashboards"
    (means they want to configure new default widgets at any time for any user)

    I was thinking that with some research, this should be possible with an additional plugin. Kevin, you clearly already have worked on this. Where are the caveats, why is this not solved yet? Is it because we do not know what widgets a profile has at any given time (so that you need to assume "...that users had no widgets") ?.

  • Fabio,

    I have a plugin that has some of this functionality.  It's basically a plugin that administers demo sites so that I can control some functionality which are to be locked, auto addition to groups, reconfigure default widgets. etc.  I did it on 1.6.1 and have been meaning to update it to 1.7 before I upload to the plugins section.  If you'd like to give it a try send me message so I can email it to you.

  • @Deds

    Why not just upload you PlugIn for the comunity ;-)


  • Dhruva,

    I intend to do that but I need to strip first for any client specific info :-).  If time permits it should be there by next week.

  • Fabio,

    The main problem that I see with the above code I posted is that users could end up with duplicate widgets if they already had one of the widgets you were inserting.

    It sounds as though your client is basically wanting a locked down set of mandatory widgets for everyone.

    You could always delete all profile widgets first before running my code if your client does not care what their users already have.

  • The quick-and-dirty way to lockdown widgets is to hide the edit page and edit widget links using CSS.