Title: Undefined Function is_user_logged_in
Last modified: June 4, 2020

---

# Undefined Function is_user_logged_in

 *  [Fabian Todt](https://wordpress.org/support/users/gaambo/)
 * (@gaambo)
 * [6 years ago](https://wordpress.org/support/topic/undefined-function-is_user_logged_in/)
 * Hi,
    I’ve got a problem on a site I manage: I just updated “Broken Link Checker”
   to the newest version (1.11.13) and encountered a 500 Error on the Site. The 
   error states a undefined method `is_user_logged_in` in the accesspress-anonymous-
   post plugin. But since this error only occurs when updating Broken Link Checker–
   so I digged into it. `is_user_logged_in` is a pluggable function which is not
   available very early and get’s called in a pre_get_posts hook by the accesspress-
   anonymous-post plugin. Until now this wasn’t a problem because the resynch method
   of blcPostTypeOverlord used a custom SQL query to get posts, but now it uses 
   get_posts which uses WP_Query and calls all those hooks – appearently before `
   is_user_logged_in` is available.
 * I’ve opened an [issue with their plugin as well](https://wordpress.org/support/topic/error-with-1-11-13-and-other-get_posts/)–
   but maybe you could do a check if `function_exists` or if it’s even the correct
   query (media query,…) in the `restrict_media_library` function. Check if the 
   function exists probably is the safest way because it’s a pluggable function 
   and not ensured to be available (see [documentation](https://developer.wordpress.org/reference/functions/is_user_logged_in/).
    -  This topic was modified 6 years ago by [Fabian Todt](https://wordpress.org/support/users/gaambo/).
    -  This topic was modified 6 years ago by [Fabian Todt](https://wordpress.org/support/users/gaambo/).
      Reason: fixed apostrophes

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Access Keys (Alson)](https://wordpress.org/support/users/alsonthakuri/)
 * (@alsonthakuri)
 * [6 years ago](https://wordpress.org/support/topic/undefined-function-is_user_logged_in/#post-12953273)
 * Hi [@gaambo](https://wordpress.org/support/users/gaambo/)
 * Thank you for writing in.
 * Could you please provide us your site URL so that we can check on this and provide
   you a better solution.
 * Regards!
 *  Thread Starter [Fabian Todt](https://wordpress.org/support/users/gaambo/)
 * (@gaambo)
 * [6 years ago](https://wordpress.org/support/topic/undefined-function-is_user_logged_in/#post-12953530)
 * Thanks for your reply.
    I can’t – I only tested the update locally before deploying
   it to the live site. The error log was just a normal fatal error that the function`
   is_user_logged_in` called in `restrict_media_library` is not defined.
 * But I think I explained the problem well:
    This plugin calls `is_user_logged_in`
   which is ([according to documentation](https://developer.wordpress.org/reference/functions/is_user_logged_in/))
   a pluggable function and isn’t ensured to be loaded when you call it too early.
   Since this plugin calls it directly in a hook (`pre_get_posts`) and it’s not 
   completely sure when this hook is called (because it get’s called in **every**
   WP Query not only in the main query) it should check if the function exists. 
   Because some plugins (like the mentioned Broken Link Checker) make a WP Query**
   before** this pluggable function is included. Wheather that is correct behaviour
   of these plugins (or any other code which does it) to make a query before init
   is not important imho, because they do it (and I’ve seen it elsewhere as well).
   Therefore a quick fix to be compatible with any plugin which does it **and** 
   adhere to the documentation I encourage and ask you to wrap the call in a `function_exists`
   conditional – or as an alternative check if the current query is even the right
   query the plugin is after (as I see it’s only meant for media queries).
 *  [Access Keys (Alson)](https://wordpress.org/support/users/alsonthakuri/)
 * (@alsonthakuri)
 * [6 years ago](https://wordpress.org/support/topic/undefined-function-is_user_logged_in/#post-12965035)
 * Hi [@gaambo](https://wordpress.org/support/users/gaambo/)
 * Thank you for writing back.
 * We will inform these issues to our developer team and release the update ASAP.
 * Please do contact us if you have any questions.
 * Regards!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Undefined Function is_user_logged_in’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/accesspress-anonymous-post_fbfbfb.
   svg)
 * [Frontend Post WordPress Plugin - AccessPress Anonymous Post](https://wordpress.org/plugins/accesspress-anonymous-post/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/accesspress-anonymous-post/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/accesspress-anonymous-post/)
 * [Active Topics](https://wordpress.org/support/plugin/accesspress-anonymous-post/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/accesspress-anonymous-post/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/accesspress-anonymous-post/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Access Keys (Alson)](https://wordpress.org/support/users/alsonthakuri/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/undefined-function-is_user_logged_in/#post-12965035)
 * Status: not resolved