Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] PHP to check if user is logged in

Simple Membership Plugin › Forums › Simple Membership Plugin › PHP to check if user is logged in

  • This topic has 6 replies, 3 voices, and was last updated 6 years, 4 months ago by Denise.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • March 1, 2020 at 3:55 pm #19861
    Denise
    Participant

    Hello! I’m using PHP to check if the user is logged in that I got off of this page: https://simple-membership-plugin.com/simple-membership-miscellaneous-php-tweaks/ I’m using it to add a class to my body tag. It worked. The problem occurred when I deactivated the plugin because of another issue. The PHP code actually caused the site to go down. I’m not a big coder. Is an else statement necessary? Would that prevent the site from going down if the plugin isn’t installed? What other ways can I accomplish adding a class to the body tag if the user is logged in? It would be extremely useful if this were part of the plugin itself!

    March 4, 2020 at 10:36 pm #19882
    mbrsolution
    Moderator

    Hi,

    I have submitted a message to the developers to investigate further your issue/question.

    Thank you

    March 4, 2020 at 10:54 pm #19884
    Denise
    Participant

    Awesome! Thank you very much!

    March 5, 2020 at 12:10 am #19885
    admin
    Keymaster

    You should check if the method exists. That will prevent any error from happening if the plugin is deactivated.

    Below is an example snippet of code to show you how to use the method_exists function of PHP

    
    <?php
    if ( method_exists('SwpmMemberUtils', 'is_member_logged_in') )
    {
        //Now lets use that function to check if the member is logged-in
        if ( SwpmMemberUtils::is_member_logged_in() ) {
            //Member is logged-in. Do something
        }
    }
    ?>
    
    March 5, 2020 at 12:23 am #19886
    Denise
    Participant

    This is exactly what I needed! Thank you! Brilliant!

    Now maybe add it to your documentation. 😉

    March 5, 2020 at 12:30 am #19887
    admin
    Keymaster

    Glad to hear that it helped.

    That documentation is actually for developers. We only want to list the helpful functions available from our plugin. It will be upto the developer as to how they want to use it. A developer will already know how best to utilize the functions.

    We don’t really want to start getting too much into implementation because different people will use it differently and then before you know it, we will have to start explaining what PHP is. That is beyond the scope of free support.

    March 5, 2020 at 1:02 am #19889
    Denise
    Participant

    Well, thank you very much for extending yourself to me for this implementation!

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

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy