Filtering Recent User Switched

Hi,

With most membership plugins,   users can also be suspended or deactivated (but not deleted).

In this scenario, they can still appear in the recently switched users since their cookie might still be valid.

I hope you may consider adding a filter to check if the user is active or not.

This would allow other plugins to integrate. Here is what I suggest:

public static function get_all_previous_switched_users() {
$cookie = self::get_previous_switched_cookie();
if (!empty($cookie)) {
$collect_users = array();
foreach ($cookie as $user) {
$user_data = get_userdata(wp_validate_auth_cookie($user, 'switched_users'));
if (FALSE !== $user_data) {
// Added Filter
$is_user_active = apply_filters('shop_as_customer_is_user_active', true, $user_data->ID);
if ($is_user_active) {
$collect_users[] = get_userdata(wp_validate_auth_cookie($user, 'switched_users'));
}
}
}
return $collect_users;
}
return false;
}

Hope you will consider this in the next versions.

Thanks Michael

Hi Michael

Thank you very much for this... I'll pass it on to our developer to implement.

Thanks

on September 7, 2016.
Add Comment
1 Answer(s)

With the new version 2 and the new hooks, there is not more issues.
Thanks guys for this awesome new version!!

Answered on September 23, 2016.

Pleasure 🙂

on September 26, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.