bp_add_caps

Add capabilities to WordPress user roles.

Description

bp_add_caps(); 

This is called on plugin activation.


Usage

  1. if ( !function_exists( 'bp_add_caps' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-caps.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_add_caps(); 
  7.  

Defined (1)

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

/bp-core/bp-core-caps.php  
  1. function bp_add_caps() { 
  2. global $wp_roles; 
  3.  
  4. // Load roles if not set. 
  5. if ( ! isset( $wp_roles ) ) { 
  6. $wp_roles = new WP_Roles(); 
  7.  
  8. // Loop through available roles and add them. 
  9. foreach( $wp_roles->role_objects as $role ) { 
  10. foreach ( bp_get_caps_for_role( $role->name ) as $cap ) { 
  11. $role->add_cap( $cap ); 
  12.  
  13. /** 
  14. * Fires after the addition of capabilities to WordPress user roles. 
  15. * This is called on plugin activation. 
  16. * @since 1.6.0 
  17. */