Upgrade Member Level After Trial Period
-
Been digging and digging and may have found my answer but want to be certain.
We’re offering membership at level 1 for $x/mo with a 14-day $1 trial so at the end of the trial they are automatically billed the monthly membership fee. What we’d like to have happen is after the 14 day trial expires and the member pays is to automatically upgrade them to level 2. Is it possible to accomplish this with a cron just as such:
<?php add_action ("init", "my_cron_job", 1); function my_cron_job () { if ($_GET["my_cron_job"] === "secret-cron-job-key") { foreach (get_users () as $user) { $user = new WP_User ($user->ID); $_15_days_ago = strtotime ("-15 days"); if (s2member_registration_time ($user->ID) <= $_15_days_ago) { # A Member for at least 15 days. # Promote them now to Level #2. if (!$user->has_cap ("access_s2member_level2")) $user->set_role ("s2member_level2"); } } /**/ exit (); } } ?>
As referenced here: https://www.s2member.com/kb/roles-caps-via-php/
Id rather it happen automatically than go the content drip route and have to add [s2Drip level=”1″ from_day=”x”][/s2Drip] shortcodes on everything we add that we want to restrict during the 14-day trial period. Because then we can just restrict page access based on membership levels and when automatically upgraded to level 2 they’ll now have access.
This is also important because we’re allowing users to upgrade manually early (before the 14-day trial period ends) and if we had drip set to x days they’d still have to wait until day 15. Thought maybe we could go the “…PAID_REGISTRATION_DAYS” content drip but thought the $1 trial would be considered paid and would give them access prematurely.
Is the cron job route the way to go to accomplish this? If so, how do we set it up to check twice a day?
Thank you!
- The topic ‘Upgrade Member Level After Trial Period’ is closed to new replies.