ap_update_caps_for_role( string $role_slug, array $caps = array() )
Description #
Update user role.
Parameters #
- $role_slugstring (Required) Role slug.
- $capsarray (Optional) Allowed caps array. Default value: array()
Source #
File: admin/functions.php
function ap_update_caps_for_role( $role_slug, $caps = array() ) { $role_slug = sanitize_text_field( $role_slug ); $role = get_role( $role_slug ); if ( ! $role || ! is_array( $caps ) ) { return false; } $ap_roles = new AP_Roles(); $all_caps = $ap_roles->base_caps + $ap_roles->mod_caps; foreach ( (array) $all_caps as $cap => $val ) { if ( isset( $caps[ $cap ] ) ) { $role->add_cap( $cap ); } else { $role->remove_cap( $cap ); } } return true; }
Expand full source code Collapse full source code View on GitHub: admin/functions.php:33
Add your comment