Title: Test PHP for logged users
Last modified: October 7, 2019

---

# Test PHP for logged users

 *  Resolved [bbr13](https://wordpress.org/support/users/bbr13/)
 * (@bbr13)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/)
 * Hi,
 * Is it possible in PHP code of a page to insert a test in order to check if the
   user is logged via “IP Based Login” or via “login + password” ?
 * Thank you to replay,
    Regards, Bruno Bros
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ftest-php-for-logged-users%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/test-php-for-logged-users/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/test-php-for-logged-users/page/2/?output_format=md)

 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12019841)
 * Hi,
 * Unfortunately at the moment this is not possible.
 * However the user does see a message in the admin panel top bar that he was logged
   in with IP Based Login plugin.
 *  Thread Starter [bbr13](https://wordpress.org/support/users/bbr13/)
 * (@bbr13)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12024019)
 * ok thank you.
    I have to display a special information message if the user is
   logged with “IP Based Login”. The information in the admin panel doesn’t help
   me.
 * Regards,
    Bruno
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12024622)
 * Hi,
 * I will add this by Tuesday and let you know.
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12025338)
 * Hi,
 * Is it Tuesday already ?
 * I have released a new version 1.4.0 which includes a function named “is_logged_in_using_ipbl”
   which will return true when a user is logged in with this plugin and will return
   false for all other cases. This function can be called from any other theme/plugin
   or any PHP file.
 * Please update the plugin and check if this works for you.
 * Let me know if you face any issues.
 *  Thread Starter [bbr13](https://wordpress.org/support/users/bbr13/)
 * (@bbr13)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12028726)
 * You are amazing.
    Iwill try this feature tomorrow and send you back the result.
   Thank you very much for reactivity, Bruno
 *  Thread Starter [bbr13](https://wordpress.org/support/users/bbr13/)
 * (@bbr13)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12030963)
 * This last feature works fine.
    Thank you again. You are great! Bruno
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12031091)
 * Hi,
 * Glad to know it works.
 * It would be great if you can leave a rating 🙂
 *  [adjunctadvocate](https://wordpress.org/support/users/adjunctadvocate/)
 * (@adjunctadvocate)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12058179)
 * So, with this update, if a user is logged in via username and password, IP Login
   will NOT be active?
 * We have library customers who want a private username and password to control
   their subscription settings, and to use IP recognition for their library users
   to view the content of the site, but NOT have access to the account settings (
   the username and password).
 * In this instance, would we need to set up TWO accounts for each library? One 
   that is username and password access (to view the user dashboard) AND IP access
   so that the library USERS can view the site content, but NOT access the user 
   dashboard?
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12060061)
 * [@adjunctadvocate](https://wordpress.org/support/users/adjunctadvocate/) This
   update does not affect any existing functionality. The whole plugin will work
   as it used to work before.
 *  [sustec](https://wordpress.org/support/users/sustec/)
 * (@sustec)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12474640)
 * Hi,
    The scenario mentioned by @adjuntadvocate is very interesting, we have a
   similar situation. However it does not work because the auto login by IP is replacing
   the login by user, causing the problem that an “admin user” cannot access from
   their center (library, or whatever) because is replacing the login by the auto
   login by IP. It would be a big step that the auto login only applies when is 
   no user logged in, so no replacing what would be a higher authentication (user/
   password).
 * [@brijeshk89](https://wordpress.org/support/users/brijeshk89/), is this attainable?
   Do you need any help or funds to improve this?
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12478060)
 * [@sustec](https://wordpress.org/support/users/sustec/) I just checked this and
   if you visit the wp-admin or wp-login.php page you will not be logged in and 
   you will see the login form which you can use to login as any user you desire.
 * IP Based Login already has the functionality that it tries to login as a user
   only if the user is not already logged in. If a user is logged in with username/
   pass this plugin does not interfere with that session.
 * Also if you are logged in a the user defined for your IP. After login you can
   hover on the “Logged in by IP Based Login” button in the top bar and you can 
   disable login temporarily and then you the plugin will not auto login and you
   can login with the username/pass with any user account.
 * Let me know if this works for you.
 *  [sustec](https://wordpress.org/support/users/sustec/)
 * (@sustec)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12483974)
 * Hi [@brijeshk89](https://wordpress.org/support/users/brijeshk89/) Thank you very
   much for your quick response.
    Well, I’m not sure what happened, it was giving
   some problem with a test where the access to the site is restricted to admin 
   users, the IP was set to a standard user, then the autologin was preventing the
   access to the page and asking every time for log in. So it looked like it was
   replacing the login. I removed that restriction, and it works as you say, the
   autologin is not replacing the user already logged. Just appears the option on
   the top bar saying “Logged in by…” even if the user remains the same (the user
   previously logged). That’s good. Your plugin is just great! I don’t want to ask
   too much, but just I would like to ask if some of these options are attainable
   and could be added eventually, because it might be a big enhancement in the plugin:–
   Autologin by URL referred, by entering URL instead IP – That the IP/URL could
   be entered in each user profile, as a field of the user account (to organize 
   easier the configuration by user). – Import/export the records (IP/users), to
   handle and creat records massively.
 * As I said before, your plugin and work are very appreciated! Anything I can help,
   let me know!
    Thank you very much!
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12486144)
 * [@sustec](https://wordpress.org/support/users/sustec/)
 * >> Just appears the option on the top bar saying “Logged in by…” even if the 
   user remains the same (the user previously logged).
 * I did notice this and I have fixed this 2 days back in v1.4.1, please check if
   you still face this issue with the latest version.
 * >> – Autologin by URL referred, by entering URL instead IP
    – Import/export the
   records (IP/users), to handle and creat records massively.
 * These two are doable and I’ll add it soon.
 * >> – That the IP/URL could be entered in each user profile, as a field of the
   user account (to organize easier the configuration by user).
 * I will review how this will work.
 * It would be great if you could leave a review for our plugin 🙂
 *  [sustec](https://wordpress.org/support/users/sustec/)
 * (@sustec)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12486286)
 * – v.14.1:
    Perfect, I updated to the last version and is fixed.
 * – URL referred, importation…
    Awesome! Thank you for taking those into consideration.
 * Of course, I just made a review, thank you very much!
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/#post-12486370)
 * Hi,
 * Glad to know it works with latest version.
 * I will update here once I add the features you requested.
 * Thank you for your feedback in improving the plugin.

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/test-php-for-logged-users/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/test-php-for-logged-users/page/2/?output_format=md)

The topic ‘Test PHP for logged users’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ip-based-login.svg)
 * [IP Based Login](https://wordpress.org/plugins/ip-based-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ip-based-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ip-based-login/)
 * [Active Topics](https://wordpress.org/support/plugin/ip-based-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ip-based-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ip-based-login/reviews/)

## Tags

 * [logged user](https://wordpress.org/support/topic-tag/logged-user/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 18 replies
 * 2 participants
 * Last reply from: [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/test-php-for-logged-users/page/2/#post-12506033)
 * Status: resolved