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.

Hook After Level Upgrade or New Regristration

Home Forums Community Forum Hook After Level Upgrade or New Regristration

This topic contains 7 replies, has 4 voices. Last updated by  it-can.ca 4 years, 8 months ago.

Topic Author Topic
Posted: Friday Apr 20th, 2012 at 5:47 pm #11423

Hello and thanks for your help.

I would like to have a fixed EOT Time (expiration time) when an existing or new user register or upgrade their access level.

I went through the API but I could not find the proper hook to perform the update for it.

I have tried these three hooks with no luck:

ws_plugin__s2member_during_paypal_notify_during_subscr_modify
ws_plugin__s2member_during_configure_user_registration_front_side
ws_plugin__s2member_during_configure_user_registration

What hook is triggered after users register on the site or upgrade their levels and the payment is confirmed by PayPal? Should I maybe use two hooks: one for new registrations and another one for level upgrades that are confirmed by PayPal?

Thanks a lot!

  • This topic was modified 4 years, 8 months ago by  it-can.ca.
  • This topic was modified 4 years, 8 months ago by  it-can.ca.
  • This topic was modified 4 years, 8 months ago by  it-can.ca.
  • This topic was modified 4 years, 8 months ago by  it-can.ca.

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Saturday Apr 21st, 2012 at 7:37 am #11497

I’ll ask Jason about the hook, but you also have the Notification API for those situations. [hilite path]Dashboard -› s2Member® -› API / Notifications[/hilite]

Posted: Monday Apr 23rd, 2012 at 9:54 am #11595

Hi Cristián,

Thanks. I also tried these three hooks (http://www.primothemes.com/forums/viewtopic.php?f=4&t=10100&hilit=reset+eot#p21726) but none of them work when I upgrade the user level from WP-Admin>Users>Role.

Is there a hook that is triggered every time the user level is changed, including new registrations, and regardless of where the change is made (backend, frontend… )?

Thanks again

Posted: Monday Apr 23rd, 2012 at 1:44 pm #11619
Raam Dev
Username: Raam
Staff Member

The set_user_role action is triggered when changing the user role and you can use that to add a function that triggers whenever the role is changed. Here’s an example that sends an email when the role is changed:
http://www.primothemes.com/forums/viewtopic.php?f=4&t=16143&p=54346#p54346

Posted: Tuesday Apr 24th, 2012 at 7:16 pm #11776
Staff Member

I agree. The hook set_user_role is your best bet in this case, as that lies beneath s2Member’s functionality, taking place in the WordPress core framework whenever a Role is changed.

Posted: Monday Apr 30th, 2012 at 3:01 pm #12223

Thanks Raam / Jason.

It works when the user is upgraded manually from WP-Admin > Users. If users just buy a higher subscription (from Level 1 to Level 2 for instance) through a PayPal button, the level is upgraded but the action (set_user_role) is never triggered after the payment.

This is what I’m trying to do:

add_action( 'set_user_role', 'expiration_date', 10, 2);
		
function expiration_date($user_id) {
	$expire_on = strtotime('04/04/2013');
	update_user_option ($user_id, "s2member_auto_eot_time", $expire_on);
}

As I said, it works when I do it from the backend but not when they complete the Payment through PayPal. Maybe the priority of the hook should be different?

Any ideas?

Thanks a lot

Posted: Wednesday May 2nd, 2012 at 4:15 am #12348
Staff Member

Thanks for the heads up on this thread.
~ and thank you VERY much for the follow-up.

the level is upgraded but the action (set_user_role) is never triggered after the payment.

If the Membership Level is changing, then by definition, the Role is also being changed, and set_user_role should be firing. I suspect that your code IS firing, but the problem in this case, is that s2Member’s routine is overriding the value that your hook is setting, later in it’s own sub-routines, after the change to the User’s Role. In other words, you’re setting s2member_auto_eot_time in your snippet, but s2Member is also handling this, which is nullifying the custom value that you’re attempting to set, after the firing of set_user_role.

Possible solution. Add your code snippet to this hook as well.

add_action('ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars', 'expiration_date');
function expiration_date($vars = array()) {
	$user_id = $vars['user_id'];
	$expire_on = strtotime('04/04/2013');
	update_user_option ($user_id, "s2member_auto_eot_time", $expire_on);
}
Posted: Wednesday May 2nd, 2012 at 11:16 am #12383

Hi Jason,

You explained exactly what was happening. The “ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars” hook works great.

Thank you VERY much for all your help.

Viewing 7 replies - 1 through 7 (of 7 total)

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.