bbdev

Multisite - Grant super admin priviledges to any user

Jul 7th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. /**
  3. * Paste this code in functions.php of your child theme.
  4. * And visit yourdomain.com/wp-admin once. Doesn't matter if you are logged-in or not.
  5. * Then remove this code!!!
  6. * Go to network-admin > users and check the super-admin tab
  7. */
  8. add_action( 'admin_init', 'bboss_make_user_superadmin' );
  9. function bboss_make_user_superadmin(){
  10.     //@todo: replace this with the real username
  11.     $username = 'andre';
  12.    
  13.     $user = get_user_by( 'login', $username );
  14.     if( !empty( $user ) ){
  15.         if( is_multisite() ){
  16.             grant_super_admin( $user->ID );
  17.         }
  18.     }
  19. }
Add Comment
Please, Sign In to add comment