latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Accessing all "After auto EOT system" users

Home Forums Community Forum Accessing all "After auto EOT system" users

This topic contains 0 replies, has 1 voice. Last updated by  aly ielts 4 years, 5 months ago.

Topic Author Topic
Posted: Wednesday Jul 25th, 2012 at 1:34 am #20148
aly ielts
Username: klc

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.

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.