📜  管理员用户 functions.php - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:07.306000             🧑  作者: Mango

代码示例1
function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user )  && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');