Page 1 of 1

PHP Coding Tips to Enhance s2member

PostPosted: March 1st, 2011, 8:28 pm
by dwdutch
In this forum, there's a mix of people who code ad those who don't. For those of us who consider using s2member for the heavy lifting of membership management but what to enhance it's capabilities via PHP, it is difficult to find straight-forward tips and tricks. Hopefully, others will add their suggestions into this thread.

As an administrator, I had a need to display the EOT for a member (i.e. not for/to a currently logged-in member). The s2member_auto_eot_time value is encoded so presenting it in a human-readable format became the challenge. I found the following code snippet quite useful:

Code: Select all
   $auto_eot_time = get_user_option ("s2member_auto_eot_time", $uid);
   $auto_eot_time = ($auto_eot_time) ? date ("m-d-y", $auto_eot_time) : "";
   echo $auto_eot_time;


You can output different formats for the date by referencing http://php.net/manual/en/function.date.php

Re: PHP Coding Tips to Enhance s2member

PostPosted: March 1st, 2011, 8:58 pm
by dwdutch
I've found the following tidbit useful to see the details and possible options for all of the custom registration fields that have been administered.

Code: Select all
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
   echo '<pre>';
   print_r($field);
   echo '</pre>';
}

Re: PHP Coding Tips to Enhance s2member

PostPosted: March 1st, 2011, 10:17 pm
by Cristián Lávaque
Nice idea!

Here's the auto EOT date code in a single line, in case you find it useful:
Code: Select all
echo ($time = get_user_option('s2member_auto_eot_time', $uid) ? date('m-d-y', $time) : ''); 

Re: PHP Coding Tips to Enhance s2member

PostPosted: March 1st, 2011, 10:19 pm
by Cristián Lávaque
dwdutch wrote:I've found the following tidbit useful to see the details and possible options for all of the custom registration fields that have been administered.


Where would you use this?

Re: PHP Coding Tips to Enhance s2member

PostPosted: March 2nd, 2011, 12:54 am
by dwdutch
I wouldn't make this info public;y visible. I just found it useful to remind myself of values that were assigned in the custom registration fields. I used a neat plug-in (http://wordpress.org/extend/plugins/shortcode-exec-php/) to create a shortcode that i dumped onto a WP page et voila! i could easily pull up the info by opening that page on a tab in my browser.