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 11 years ago by
admin.
-
AuthorPosts
-
October 25, 2015 at 8:25 pm #13209
appyman
MemberI’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 #71719admin
KeymasterIf 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.
October 26, 2015 at 8:12 pm #71720appyman
MemberOh 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 #71721appyman
MemberOh, 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 #71722admin
KeymasterOur eMember functions required the eMemember ID.
-
AuthorPosts
- You must be logged in to reply to this topic.