Snippet: PHP Snippet Assigning roles

This is compatible with eZ Publish 4.

This is a Stub article. Help the eZ Publish community by expanding it!

Predefined variables

  • $roleID: ID of the role
  • $objectID: id of a user or user group content object you want to assign the role to
  • $limitIdent: either null, Subtree or Section
  • $limitValue: either null, a node path string (in case $limitIdent is 'Subtree') or a section id (in case $limitIdent is 'Section')
$role = eZRole::fetch( $roleID );
$role->assignToUser( $objectID, $limitIdent, $limitValue );
 
eZRole::expireCache();
eZContentCacheManager::clearAllContentCache();
eZUser::cleanupCache();