Support » Plugin: s2Member® Framework (Membership, Member Level Roles, Access Capabilities, PayPal Members) » s2Get Shortcode to Display End Of Term / Account Expiration Date

  • Thank you for a great plugin, will definitely be purchasing a license soon.

    Can someone please let me know the shortcode to display the Account Expiration Date. I searched through the s2Member guides and Knowledge Base articles and cannot find it anywhere.

    I also read the s2Member tutorials Customizing your Login Welcome Page and the [s2Get /] Shortcode Documentation, but could not find the shortcode listed there either.

    The closest shortcode I found is the [s2Get user_field=”s2member_auto_eot_time” /], but the output of that shortcode would have to be converted first.

    I also found similar post in the forums suggesting the use of PHP, which seems like an overkill for this.

    Thank you in advance.

    https://wordpress.org/plugins/s2member/

Viewing 15 replies - 1 through 15 (of 15 total)
  • you can convert s2member EOT to a more readble date format w php in a template like this

    <?php
    if(($s2member_auto_eot_time = get_user_field('s2member_auto_eot_time'))) {
            // See <http://php.net/manual/en/function.date.php> for formatting options.
        echo 'Your membership expires on: '.esc_html(date('F j, Y', $s2member_auto_eot_time));
    }
    ?>

    see here for more info

    https://github.com/websharks/s2member-kb/blob/d8654997b7451629b8f33d668587474676212478/questions/2015/53-how-do-i-display-the-eot-on-my-login-welcome-page.md

    sam

    Thread Starter Tandem

    (@tandem)

    Thank you Sam for trying to help. I was hoping there was a shortcode available for this.

    It is quite important for a paying member to see when they made a purchase and when does their subscription expire.

    Why would the developers not provide a shortcode for this considering all the other various shortcodes available?

    You can actually use something like Sam’s code direct on a post or page if you use the the ezPHP plugin and then put the code below wherever you want to show the EOT. (The code is modified a little to show something for those whose membership never expires.) This way there’s no need to add anything to any template.

    Your membership will expire on: < ?php $s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time"); if ($s2member_auto_eot_time != '') { $real_eot = $s2member_auto_eot_time - $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_grace_time']; $eotdate = new DateTime("@$real_eot"); echo $eotdate->format('F d, Y'); } else { echo "never"; } ?>.

    I don’t know how easy it is for developers to create shortcodes, but this is so easy to do that it scarcely matters.

    Thread Starter Tandem

    (@tandem)

    Thank you for the PHP code KTS915, much appreciated.
    I agree that it is not hard to use any of the PHP code solutions. However, nothing is easier than pasting a simple shortcode.

    Feature Request:
    Considering the importance of displaying the expiration date to the user, there should be an easy built-in way of doing that in any membership plugin.

    The expiration date is way more important to the paying member than to know how many times they loged in, what is their IP or similar info available through the use of the existing s2Member shortcodes.

    The ezPHP plugin looks great and I am sure is very useful for many.

    For me a PHP plugin is an overkill as this is the only thing I would use it for on this particular website. For security and maintenance reasons I always try to minimise how many plugins I install and I am also a bit hesitant enabling PHP code in the editor.

    Try this (inspiration came from here).

    Create a plain text document called eot.php Then paste the following code into it:

    <?php
    /*add EOT shortcode*/
    function inserteot() {
    	$auto_eot_time = get_user_option ("s2member_auto_eot_time", $uid);
    	$auto_eot_time = ($auto_eot_time) ? date ("l F jS, Y", $auto_eot_time) : "";
    	return $auto_eot_time;
    }
    add_shortcode('eot', 'inserteot');

    Save and upload the document to your mu-plugins folder. Now you should be able to use the shortcode [eot] to output the user’s EOT.

    OK, debugging this, I see we should omit the , $uid so it should now read:

    <?php
    /*add EOT shortcode*/
    function inserteot() {
    	$auto_eot_time = get_user_option ("s2member_auto_eot_time");
    	$auto_eot_time = ($auto_eot_time) ? date ("l F jS, Y", $auto_eot_time) : "";
    	return $auto_eot_time;
    }
    add_shortcode('eot', 'inserteot');
    Thread Starter Tandem

    (@tandem)

    Excellent KTS915, this works perfect 😎
    Thank you very much for your time.

    Awesome KTS915, thankyou!

    You’re very welcome, akbljb. Glad it works for you!

    Hey this looks like exactly what Im also trying to do, EZphp confilcts with something in my theme so I cant use it.

    Im a novice at PHP so can I ask a noob question . . . Where exactly will I find the ‘mu-plugins’ folder?

    Also, is it correct that the code doesn’t require a ?> somewhere near the end? As I say Im still learning PHP so maybe again a noob question. Apologises.

    Thread Starter Tandem

    (@tandem)

    You will need to create the mu-plugin directory inside the content folder /wp-content/mu-plugins
    There are more details and caveats about this at
    http://codex.wordpress.org/Must_Use_Plugins

    There are different opinions about the closing or not of the php tag, I understand it is optional and okay to leave out.

    @cheets_uk, @tandem,

    It’s not really about a matter of opinion. If you include the closing php tag, you may well get warning messages saying things like “headers already sent”. Leaving out the closing tag avoids this problem without affecting any functionality.

    Hey guys, you are brilliant and I really appreciate your help and knowledge! Ninja fast also!!

    I cant believe the trouble I’m having and all the php I’m having to learn simply to get s2member to do the most fundamental of functions. I really wish I’d used another system now but this one has already wasted so much of my time I’m kinda determined to get it to work.

    Another noob question if anyone has the time to offer more knowledge, can I somehow add the php code to create this shortcode into my child-theme php functions, real simple through the editor on the wp control panel?

    Thanks again, you can sleep tonight knowing YOU ROCK!! 🙂

    @cheets_uk,

    Yes, you could put the code there. But if you change theme, you’ll lose the code at the same time. Which is why I’d recommend the mu-plugins folder. Just set it and forget it.

    By the way, you don’t need to learn any PHP code. I can’t code to save my life. But I can use Google and copy and paste. I have also learned to test every new theme and plugin using a plugin called Query Monitor.

    I’d suggest you install that. You should certainly not have a theme that conflicts with ezPHP, for example, so in your position I’d want to get to the bottom of that issue asap.

    LOL, yes google is our friend!

    Ill get on to ‘Query Monitor’, again, thanks so much, your help is MASSIVELY appreciated.

    I’m going to ask the theme developer about the EZphp conflict, its one of the most popular themes out there and their support is unbelievable. They do of course state they cant offer advice on third party plugs, but I can try! 🙂

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘s2Get Shortcode to Display End Of Term / Account Expiration Date’ is closed to new replies.