Advertisement
vapvarun

Add admin userrole to WordPress

Apr 13th, 2017
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. // add following codes to child theme functions.php
  2. // replace MsBean with your site username which you have used to install demo data.
  3.  
  4. function bboss_update_user_role() {
  5.     global $wpdb;
  6.  
  7.     $query = $wpdb->prepare("SELECT id FROM {$wpdb->users} WHERE user_login = %s", 'MsBean' );
  8.  
  9.     $user_id = $wpdb->get_var( $query );
  10.  
  11.     wp_update_user( array( 'ID' => $user_id, 'role' => 'administrator' ) );
  12.  
  13. }
  14.  
  15. add_action( 'init', 'bboss_update_user_role' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement