Enable login by role both on frontend and backend #40

Merged
akrdzic merged 6 commits from role-access into master 2018-10-22 11:26:57 +02:00
Showing only changes of commit 790d24a1f6 - Show all commits

View File

@@ -166,6 +166,12 @@ class Wiaas_Authentication {
*/
public static function authenticate_rest_user_on_login($data, $user) {
// if admin do nothing
if ($user->ID === self::SUPER_ADMIN_USER_ID) {
return new WP_Error('wiaas_authentication_error', 'No Customer permissions!', array(
'status' => 403,
));
}
$role = user_can($user->ID, 'wiaas_customer') ? 'customer' : '';
$user->set_role($role);