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.

Copy EOT to a Custom During the Auto EOT

Home Forums Community Forum Unofficial Extensions/Hacks Copy EOT to a Custom During the Auto EOT

This topic contains 0 replies, has 1 voice. Last updated by  Brad Severance 3 years, 2 months ago.

Topic Author Topic
Posted: Thursday Oct 17th, 2013 at 2:58 am #60422

Hi Guys,
I’m working on a hack that basically copies the EOT Date to a Custom Field before the EOT Date gets deleted when a user gets demoted.

The problem I’m having is that the EOT Date is being deleted before the hook can have a chance to grab the value.

Please consider the auto-eots.inc.php file. On line 122, the eot date gets deleted

delete_user_option /* Always delete. */ ($user_id, "s2member_auto_eot_time");

Then later on, after a few hooks where I could capture the EOT date, this line is duplicated on 165.

To me, the line on 122 is superfluous. If I comment it out, then I can grab the value before it gets deleted on line 165.

Generally I suppose that the demotion date and the EOT will be the same and that I could use the demotion date, but suppose the the process runs at 12:01 am or something like that.
Also, in my particular situation, which I grant is somewhat unusual, my client has to manually enter a past date in the EOT field, which will get lost when the auto-eot process runs.

My code looks like this, which will capture the actual EOT date, if line 122 is commented out, and use the current date if it isn’t:

add_action('ws_plugin__s2member_during_collective_mods','update_expired_customs',10,2);
function update_expired_customs ($user_id, $defined_vars)
{
$display_role = get_user_field("s2member_access_label", $user_id);
$eot_date = get_user_field("s2member_auto_eot_time", $user_id);
if (!$eot_date || $eot_date == ""){
$eot_date = date("m/d/Y");
}else{
$eot_date = date("m/d/Y",$eot_date);
}
$custom_fields = get_user_option('s2member_custom_fields', $user_id);
$custom_fields['expired_from_role'] = $display_role;
$custom_fields['old_eot_date'] = $eot_date;
update_user_option($user_id, 's2member_custom_fields', $custom_fields);
}

So, I’m suggesting that line 122 be removed.

Thanks!
brad

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.