is_user_logged_in() function not working in wordpress plugin Show warning like below:
Fatal error: Call to undefined function is_user_logged_in() in
How can I use the logic in wordpress plugin?
is_user_logged_in() function not working in wordpress plugin Show warning like below:
Fatal error: Call to undefined function is_user_logged_in() in
How can I use the logic in wordpress plugin?
Plugins are loaded prior to
pluggable.php
, which is whereis_user_logged_in()
is located. Which means the function doesn't exist yet when you're trying to call it. Instead, do this:Try with
is_user_logged_in()
is located in wp-includes/pluggable.php. So please include this file in your plugin file and check.EDIT:
is_user_logged_in()
is a pluggable function and you could get a fatal error if you call it too early. You can use this function inside your theme files without any additional code. Like:But inside plugin you should wait for wordpress to be loaded.
P.S. Sorry for my english.