Unregistering an action in Elgg 1.7

I've found that in elgg 1.8 is available the elgg_unregister_action function, but it isn't available in 1.7. So, what's the correct way to unregister an action? 

I've come with this approach

if (isset($CONFIG->actions[$action])) {

  unset($CONFIG->actions[$action]);

}

Or should I register the action with a new void action?

Is this a good way to prevent certain users to execute certain actions?

 

Thanks for your help in advance.

  • I think if there is no API method what you have there is fine.

    Depending on the logic you want to do to prevent users doing the action, you can either unregister it globally for everyone, or put that in an if statement where you weed out who's not allowed to do it.

    Or you can return false in the 'action',[action] plugin hook

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking