为什么首先要创建自定义表?有一个wp\\u usermeta表,用于存储任何类型的额外数据,以构建具有额外字段的自定义用户配置文件。
此外,您还可以连接到本机WP登录过程,并允许使用电子邮件登录。
您使用的登录方法是什么?
检查用户是否为管理员:
if ( current_user_can( \'manage_options\' ) ) {
/* A user with admin privileges */
wp_redirect( \'YOUR_TARGET_ABSOLUTE_URL\' );
exit;
}
但还有更好的方法,如法典所述:
function my_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if ( in_array( \'administrator\', $user->roles ) ) {
// redirect them to the default place
return $redirect_to;
} else {
return home_url();
}
} else {
return $redirect_to;
}
}
add_filter( \'login_redirect\', \'my_login_redirect\', 10, 3 );
这个函数很容易解释。将$redirect\\u to destination更改为您选择的一个。