Advertisement
avanrossum

Fix Orphaned Wordpress User on Login

Mar 5th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. //Could probably use a little cleaning up, but it works.
  2. $current_user = wp_get_current_user();
  3. if ( !(0 == $current_user->ID) ){
  4.     $user_info = get_userdata($current_user->ID);
  5.     $user_array = $user_info->roles;
  6.     if (empty($user_array)){
  7.         $u = new WP_User( $current_user->ID );
  8.         $u->add_role( 'subscriber' );
  9.     }
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement