- This topic has 4 replies, 2 voices, and was last updated 9 years ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eMember › eMember – check whether membership is expired or not using PHP (not shortcode)
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?
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
There PHP examples there also.
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');
}
Oh, one further question.
When using wp_emember_get_user_details_by_id
, is the eMember ID the same as the WordPress User ID?
Our eMember functions required the eMemember ID.