Restricting access to plugin widget(s)

Is it possible to completely remove the "Public" visibilty from a widget? Or, completely restrict it to being visible as "Private" only?


  • Yes.

    Of course almost anything is possible. So what is your question really?

    Do you want to know if

    a. this is a built-in feature and you somehow missed it?

    b. there is an existing plugin to do this and you don't want to Google for it?

    c. you want advice on how to code such a feature?

    d. you want to hire someone to code this for you?

    Almost every week someone posts a message asking "Is it possible to ...".

    The answer almost inevitably is "Yes". But I wonder if that is really the answer that the poster is looking for.

  • Thanks for the reply Kevin.

    I'm primarliy looking for this as a built in feature (either as part of the administration interface, OR as part of the Elgg programming API.. via plugin init/a plugin hook etc.).

    To elaborate: this is for a plugin/widget I'm building and therefore have full control (Although I would certainly want to stay away from touching the Elgg core..)



  • If you want to do this for all widgets, override the view 'views/default/forms/widgets/save' and explicitly pass the access levels that you want to allow.

  • You will want to override the input/access view and change its behaviour when in the "widgets" context.

  • And what Cash said. You will probably want to do both things.

  • ah wait. Actually I think Cash's solution makes mine unnecessary as the input/access view is called by the one he mentions for widgets.

  • Note: my solution is for Elgg 1.8. If using 1.7.x, use Kevin's solution.

  • Thanks for the suggestions; I will override 'views/default/forms/widgets/save' for the time being.

    However, I'm seeing a $vars['show_access'] (in save.php) that governs whether or not to show the access controls. Completely unsure as to where that needs to be set though -- would you happen to have any idea?