ngg_set_capability

The NextGEN Gallery ngg set capability function.

Description

ngg_set_capability( $lowest_role, $capability ); 

Parameters (2)

0. $lowest_role
The lowest role.
1. $capability
The capability.

Usage

  1. if ( !function_exists( 'ngg_set_capability' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/admin/roles.php'; 
  3.  
  4. // The lowest role. 
  5. $lowest_role = null; 
  6.  
  7. // The capability. 
  8. $capability = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ngg_set_capability($lowest_role, $capability); 
  12.  

Defined (1)

The function is defined in the following location(s).

/products/photocrati_nextgen/modules/ngglegacy/admin/roles.php  
  1. function ngg_set_capability($lowest_role, $capability) { 
  2. // This function set or remove the $capability 
  3. $check_order = ngg_get_sorted_roles(); 
  4.  
  5. $add_capability = false; 
  6.  
  7. foreach ($check_order as $the_role) { 
  8. $role = $the_role->name; 
  9.  
  10. if ( $lowest_role == $role ) 
  11. $add_capability = true; 
  12.  
  13. // If you rename the roles, then please use a role manager plugin 
  14.  
  15. if ( empty($the_role) ) 
  16. continue; 
  17.  
  18. $add_capability ? $the_role->add_cap($capability) : $the_role->remove_cap($capability) ;