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

Expired & Not logged in user levels with PHP code

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › Expired & Not logged in user levels with PHP code

Tagged: membership levels

  • This topic has 5 replies, 2 voices, and was last updated 4 years, 9 months ago by admin.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 11, 2020 at 12:02 pm #15637
    sion
    Participant

    Hi

    I am using:

    <?php if(wp_emember_is_member_logged_in(‘1’)) { ?>

    //Place your special message for members from membership level with ID 1

    <?php } ?>

    To display custom content to subscribing members. What i am trying to achieve is to display custom content for when a user is not logged in & different content when a subscription has expired/cancelled.

    I was wondering what membership levels i can use for each of these please?

    I am not using the standard “join us” pages etc as i am trying to create a simple process that works with my site & that’s why im using the PHP scripts.

    Thanks

    August 12, 2020 at 2:27 am #80855
    admin
    Keymaster

    Below is an example of what you can use to show something to “non-logged” visitors:

    <?php if(!wp_emember_is_member_logged_in()) { ?>
    //Place your content that is shown to visitors who are not logged-in
    <?php } ?>

    To show a message to users who are logged-in but membership expired, you can use the following:

    <?php
    if (emember_check_all_subscriptions_expired()) {
    //The user is logged-in but account has expired.
    //Show a message to them.
    }
    ?>

    The following page has some useful function references:

    https://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-miscellaneous-tweaks-248

    August 14, 2020 at 10:31 am #80856
    sion
    Participant

    Thanks for the reply

    The non-logged in one works great. The expired accounts one isn’t for some reason. I am getting this error:

    Fatal error: Uncaught Error: Call to a member function get() on null in /home/website/public_html/website/wp-content/plugins/wp-eMember/includes/emember_utils_auth.php:554 Stack trace: #0 /home/website/public_html/website/wp-content/plugins/wp-eMember/includes/emember_utils_auth.php(653): wp_emember_is_expired(NULL, NULL) #1 /home/website/public_html/website/wp-content/plugins/wp-eMember/lib/class.emember_auth.php(699): wp_emember_is_subscription_expired(NULL, NULL) #2 /home/website/public_html/website/wp-content/plugins/wp-eMember/emember_access_checkers.php(500): Emember_Auth->is_subscription_expired() #3 /home/website/public_html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65) : eval()’d code(1): emember_check_all_subscriptions_expired() #4 /home/website/public_html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65): eval() #5 /home/website/public_html/website/wp-includes/shortcodes.php(343): xyz_ips_display_c in /home/website/public_html/website/wp-content/plugins/wp-eMember/includes/emember_utils_auth.php on line 554

    August 15, 2020 at 12:39 am #80857
    admin
    Keymaster

    Check that a user is logged-in before calling that “emember_check_all_subscriptions_expired()” function.

    So try something like the following:

    <?php
    if ( wp_emember_is_member_logged_in() )
    {
    //We have a logged-in user. So now we can check if his account is expired or not.
    if ( emember_check_all_subscriptions_expired() ) {
    //The user is logged-in but account has expired.
    //Show a message to them.
    }
    }
    ?>

    August 15, 2020 at 4:42 pm #80858
    sion
    Participant

    Thank You

    I am now having this issue. After adding the content i am putting <?php } ?> at the end of the code but i am getting this error: Parse error: syntax error, unexpected ‘}’, expecting end of file in…

    August 16, 2020 at 1:09 am #80859
    admin
    Keymaster

    Your script has some coding error somewhere (not necessarily on the line it is complaining about). Some of these PHP errors are a little bit cryptic if you are not a PHP developer. I thought you are a PHP coder.

    It will need to debugged to see where things are going wrong. This is beyond the scope of this forum. You will need to use the following option for customization like this:

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

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