Wordpress Change Default Display Name Publicy As for all existing users

前端 未结 6 604
耶瑟儿~
耶瑟儿~ 2021-02-05 23:58

does anyone know of way I can change the existing display name publicly as for all users. I want to have firstname lastname as the default because this will reflect in the forum

6条回答
  •  梦毁少年i
    2021-02-06 00:13

    'all'));
    
        foreach($users as $user){   
            $user = get_userdata($user->ID);    
    
            $display_name = $user->first_name . " " . $user->last_name;
    
            if($display_name!=' ') wp_update_user( array ('ID' => $user->ID, 'display_name' => $display_name) );
                else wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
    
            if($user->display_name == '') 
                wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
        }   
    }
    
    ?>
    

提交回复
热议问题