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

eMember – check whether membership is expired or not using PHP (not shortcode)

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › eMember – check whether membership is expired or not using PHP (not shortcode)

  • This topic has 4 replies, 2 voices, and was last updated 9 years, 7 months ago by admin.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • October 25, 2015 at 8:25 pm #13209
    appyman
    Member

    I’ve built a plugin that allows different functions to different membership levels.

    This works perfectly except for when a member’s subscription (of any level) expires. The plugin should reduce functionality but, having searched high and low, I can’t figure out how to programmatically determine whether a member’s subscription is valid or not.

    I’ve found the [emember_protected] shortcode but that can’t be used in PHP code.

    Using

    emember_auth = Emember_Auth::getInstance();
    if($emember_auth->is_protected_post($post_id))
    {
    //This member is allowed to see this post
    }

    doesn’t solve the problem either because I need to establish whether the logged in member’s subscription has expired at a global level, not post specific.

    I can’t imagine this isn’t a possibility.

    Can anyone point me in the right direction?

    October 25, 2015 at 11:44 pm #71719
    admin
    Keymaster

    If the member’s account status is not “active” then that means his time is up. So don’t you only have to check that member’s account status and determine if the account is active or not?

    The following posts have examples of how you can retrieve a member’s particular detail (in this case the “account state”)

    How to Retrieve and Show Specific Details of the Logged-in Member

    How to Retrieve and Show Details of a Specific Member

    There PHP examples there also.

    October 26, 2015 at 8:12 pm #71720
    appyman
    Member

    Oh my word. I looked through both those posts before posting this one and I totally missed that!

    Thank you.

    If this helps anyone else, this code I am using is

    $user_active = true;
    if (function_exists('wp_emember_get_user_details')) {
    $user_active = wp_emember_get_user_details('account_state');
    }

    October 26, 2015 at 8:59 pm #71721
    appyman
    Member

    Oh, one further question.

    When using wp_emember_get_user_details_by_id, is the eMember ID the same as the WordPress User ID?

    October 26, 2015 at 11:36 pm #71722
    admin
    Keymaster

    Our eMember functions required the eMemember ID.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 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