Hello,
How does one access all the users being demoted when the ws_plugin_s2member_after_auto_eot_system hook is called?
The following code only works when one user is demoted.
Can’t figure out what $vars will look like if there are more than 1 user being demoted at a time.
Code below only does something to one of the users being demoted.
add_action("ws_plugin__s2member_after_auto_eot_system", "mtq_keepUserCustomCap");
function mtq_keepUserCustomCap($vars = array())
{
$user = $vars['user']; // WP_User object instance.
$user_id = $user->ID;
$user_name = strtolower($user->user_login); //custom caps will default to lowercase anyway
$ccap = "access_s2member_ccap_".$user_name;
if(user_cannot($user_id, $ccap)){
$user->add_cap($ccap);
error_log("Adding custom cap: $ccap back to $user_name", 0);
}
}
Background:
When a members profile EOT is reached the custom capabilities associated with that user are removed.
I currently have a custom capability = to the users login for each user registered for the site.
I wanted to make sure this didn’t get removed when they are demoted.
The code above only works if one user is being demoted.
If there is more than one member being demoted only the 1st one gets their custom capability added back.
I’m missing documentation on what the $var array will look like if there are mutliple users.
Clearly i have to iterate over them and add their custom capabilities back but i’m am unable to figure out how to access the array of users that have been demoted.