wp登录反对用户角色

I'm using this code-

$info = array();
    $info['user_login'] = $_POST['username'];
    $info['user_password'] = $_POST['password'];
    $info['remember'] = true;

    $user_signon = wp_signon( $info, false );

    if ( is_wp_error($user_signon) ){
        echo json_encode(array('loggedin'=>false, 'message'=>__('Wrong username or password.')));
    } else {
        echo json_encode(array('loggedin'=>true, 'message'=>__('Login successful, redirecting...')));
    }

    die();

Login is working fine.But how can i restrict a user with editor role in this function so that i can check the role and if its there then i will pass a custom error message in the json?

查看全部
weixin_33749242
weixin_33749242
2016/11/11 07:40
  • wordpress
  • ajax
  • 点赞
  • 收藏
  • 回答
    私信

1个回复