PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

PHP Coding Tips to Enhance s2member

s2Member Plugin. A Membership plugin for WordPress®.

PHP Coding Tips to Enhance s2member

Postby dwdutch » March 1st, 2011, 8:28 pm

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
User avatar
dwdutch
Registered User
Registered User
 
Posts: 24
Joined: January 16, 2011

Re: PHP Coding Tips to Enhance s2member

Postby dwdutch » March 1st, 2011, 8:58 pm

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>';
}
User avatar
dwdutch
Registered User
Registered User
 
Posts: 24
Joined: January 16, 2011

Re: PHP Coding Tips to Enhance s2member

Postby Cristián Lávaque » March 1st, 2011, 10:17 pm

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) : ''); 
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: PHP Coding Tips to Enhance s2member

Postby Cristián Lávaque » March 1st, 2011, 10:19 pm

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?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: PHP Coding Tips to Enhance s2member

Postby dwdutch » March 2nd, 2011, 12:54 am

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.
User avatar
dwdutch
Registered User
Registered User
 
Posts: 24
Joined: January 16, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 10 guests

cron