grant_super_admin()
Grants Super Admin privileges.
Uses: update_site_option()
Hooks from the function
Return
true|false
. True on success, false on failure. This can fail when the user is already a super admin or when the $super_admins global is defined.
Usage
grant_super_admin( $user_id );
- $user_id(int) (required)
- ID of the user to be granted Super Admin privileges.
Examples
#1 Give super admin rights (caps) to the user with ID 5
It is recommended to call the function only once, not every time the page is generated. Because it changes the value of the option.
grant_super_admin( 5 );
#2 Set super-admin rights (caps) and remove them when activating/deactivating the plugin
register_activation_hook( __FILE__, 'myplugin_activate' ); register_deactivation_hook( __FILE__, 'myplugin_deactivate' ); function myplugin_activate() { // give caps grant_super_admin( 5 ); } function myplugin_deactivate(){ // take away the caps revoke_super_admin( 5 ); }
Notes
- Global. Array. $super_admins
Changelog
Since 3.0.0 | Introduced. |