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™

converting unix timestamps in shortcode

s2Member Plugin. A Membership plugin for WordPress®.

converting unix timestamps in shortcode

Postby doctorproctor » June 4th, 2011, 12:16 am

I want to convert the EOT timestamp into a normal date, ideally using shortcode to keep it simple. In another thread, you alluded to the possibility of converting a UNIX timestamp via PHP; can this work in conjunction with an s2 shortcode on a page?

I'm new to this, but it looks like in order to execute PHP within a WP page we need to use a plugin such as Shortcode Exec PHP. The PHP side of it is pretty simple, but can one execute a shortcode inside another shortcode in WordPress? I'd appreciate a simple example using

[s2Get user_option="s2member_auto_eot_time" /]

as my PHP script is not quite working yet. (I've got this nested inside an [s2If] statement.)

Thanks!

Jim
User avatar
doctorproctor
Registered User
Registered User
 
Posts: 37
Joined: May 18, 2011

Re: converting unix timestamps in shortcode

Postby Cristián Lávaque » June 4th, 2011, 12:17 am

This may help you viewtopic.php?f=36&t=1604 :)
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: converting unix timestamps in shortcode

Postby doctorproctor » June 6th, 2011, 8:01 pm

Thanks for the quick reply! Just took a look, and this seems to work for PHP inside an s2 shortcode, but what I need is the reverse, i.e. shortcode supplies date inside Unix to PHP date function, e.g. "Your membership expires on <?php echo date('l F jS, Y','[s2Get user_option="s2member_auto_eot_time" /]') ?>." I can insert a literal Unix date in the above and it works fine, but the shortcode generates errors.

Thanks,

Jim
User avatar
doctorproctor
Registered User
Registered User
 
Posts: 37
Joined: May 18, 2011

Re: converting unix timestamps in shortcode

Postby Cristián Lávaque » June 7th, 2011, 2:07 am

Ah, ok Jim, I see now what you are trying to do. Sorry I didn't understand the first time. Try this:

Code: Select all
echo date('l F jS, Y'get_user_option('wp_s2member_auto_eot_time'$user_id)); 


http://codex.wordpress.org/Function_Ref ... ser_option

I hope that helps. :)
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: converting unix timestamps in shortcode

Postby doctorproctor » June 7th, 2011, 10:48 am

This works! Thank you.

Jim
User avatar
doctorproctor
Registered User
Registered User
 
Posts: 37
Joined: May 18, 2011

Re: converting unix timestamps in shortcode

Postby Cristián Lávaque » June 7th, 2011, 11:28 am

Cool. :)
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


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron