[development] modify permissions using hook_menu_alter()

Earnie Boyd earnie at users.sourceforge.net
Tue Apr 28 19:29:24 UTC 2009


Quoting Lluís <enboig at gmail.com>:

> Well, that was an example, the permission of a user to belong to a
> role or not can change during its session; so I need a way to make it
> change dynamically during the session.
>

If you want to trap the user to a new set of permissions during the  
session you would need to use hook_form_alter and reload the global  
$user.  Something like the untested function

function foo_form_alter(&$form, &$form_state, $form_id) {
   global $user
   $user = user_load(array('uid' => $user->uid));
}

This would reload the $user object for each form modifying the roles  
to the current set.  If you only want certain forms to do this you can  
filter with the form id.

--
Earnie
-- http://r-feed.com/           -- http://for-my-kids.com/
-- http://www.4offer.biz/       -- http://give-me-an-offer.com/



More information about the development mailing list