Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

How do I determine the number of days left until account expiry?

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › How do I determine the number of days left until account expiry?

Tagged: Expiry, wp membership

  • This topic has 8 replies, 2 voices, and was last updated 11 years, 6 months ago by sandyfootprints.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • October 18, 2013 at 1:21 pm #9871
    sandyfootprints
    Member

    Hi

    I would like to add some php into a page to show a message to a logged in member if their account is due to expire within the next 10 days – i.e. if their account is due to expire show the link to the membership renewal payment page…

    Can you tell me how to access this information/set this up?

    Thanks :)

    October 18, 2013 at 1:25 pm #58379
    sandyfootprints
    Member

    Also, if the account has passed its expiry date is there a php variable I can use to define a different menu on the site (I have already set up the different menus based on different logged in membership levels.

    Thanks!

    October 18, 2013 at 11:09 pm #58380
    admin
    Keymaster

    You could use the “Email user before the account expires” feature to notify the member X days before his/her account expires. You can enable that feature from the Email Settings menu of the plugin. Will that work? If you can use that feature then you don’t have to add custom tweaks.

    I am guessing you are allowing expired user to log into the site. Here is a snippet of example code to retrieve a member’s account status.

    <?php
    $emember_auth = Emember_Auth::getInstance();
    $user_id = $emember_auth->getUserInfo('member_id');
    if (!empty($user_id))
    {
    //User is logged in so add your code to retrieve account status
    $account_status = $emember_auth->getUserInfo('account_state');
    if($account_status != 'active')
    {
    //This member's account is not active, do something about it!
    }
    }
    ?>

    October 19, 2013 at 10:11 am #58381
    sandyfootprints
    Member

    Hi,

    Thanks for your help, but I would like to be able to display custom information based on whether the users account is near or has passed expiry. Is there some php you could give me to handle that?

    Thanks

    October 19, 2013 at 10:33 am #58382
    sandyfootprints
    Member

    also, i need to be able to display different renewal buttons based on the current membership level of the expired account – i have tried to do this using

    wp_emember_is_member_logged_in('7')

    etc with the different membership levels to define various content within the page but these don’t seem to apply once the account is set as expired – please can you advise?

    October 19, 2013 at 11:07 pm #58383
    admin
    Keymaster

    Actually you don’t need to show renewal buttons based on the users level. When their account is expired, emember will prompt them to renew and you can specify a renewal URL where members can go and click on a button. Read this documentation:

    http://www.tipsandtricks-hq.com/wordpress-membership/how-to-create-payment-buttons-for-membership-upgrade-189

    This renewal URL can be the same as the “Join US” page. When members go to that renewal page, they can select which option they want to take for the renewal. So it is completely okay to have a list of all the renewal buttons for each of your levels and the member will pick the one accordingly.

    Additionally, you can protect each renewal button (on the renewal page) using emember’s section protection shortcode. Details here:

    http://www.tipsandtricks-hq.com/wordpress-membership/how-to-protect-a-section-of-a-post-or-page-88

    That way, a logged in member will only see the renewal button for that level (I think this is kind of what you are trying to do).

    October 20, 2013 at 9:41 am #58384
    sandyfootprints
    Member

    hi,

    that still doesn’t help me acheive what i need. if the account is expired using

    [emember_protected for=3]
    [/emember_protected]

    doesn’t work – the content doesn’t show even though the member is logged in at the level because the account is expired.

    I need to show specific renewal buttons for subscription costs because the membership levels are set by admin and the end user shouldn’t have the choice of a membership level to renew to.

    so – I need to be able to show specific content based on membership level even when the account has expired.

    Also – I would like to display in the membership page:

    ‘Your account has X days until it expires – please renew your subscription fees at this link’

    How can I achieve this?

    Thanks

    October 20, 2013 at 11:11 pm #58385
    admin
    Keymaster

    I was trying to give you ways to achieve what you are after without having to do custom tweaks/modifications.

    Here is an example of how you can retrieve the expiry date of the logged in member:

    <?php
    $emember_auth = Emember_Auth::getInstance();
    $user_id = $emember_auth->getUserInfo('member_id');
    if (!empty($user_id))
    {
    //User is logged in so lets check the member's expiry date
    $expiry_date = emember_get_expiry_by_member_id($user_id);

    //Now do something with this expiry date
    echo "<br />Expiry Date: ".$expiry_date;
    }
    ?>

    If you need someone to create a custom function for you then you can use this form:

    https://support.tipsandtricks-hq.com/need-custom-work-done

    October 21, 2013 at 8:59 am #58386
    sandyfootprints
    Member

    That’s perfect thank you! I’ve managed to do exactly what I needed:

    <?php
    $emember_auth = Emember_Auth::getInstance();
    $user_id = $emember_auth->getUserInfo('member_id');
    if (!empty($user_id))
    {
    //User is logged in so lets check the member's expiry date
    $expiry_date = emember_get_expiry_by_member_id($user_id);
    $today = date('Y-m-d');
    $datediff = strtotime($expiry_date) - strtotime($today);
    $numtilexpire = floor($datediff/(60*60*24));</p>
    if ($numtilexpire < 11) {
    echo '<p>You have '.$numtilexpire.' days until your membership expires. Renew link here.</p>';
    }
    }
    ?>

    Thank you very much for all your help and patience! :)

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ