I have saved my custom plugin settings inside wp_options table, but when I try to access them using "get_option" function it returns me undefined for logout users, but when I logged in it returns me the accurate value saved in the table, anyone can help me why is that happening or is it the default behavior?

this is how I am adding the option in wp_options table:

 add_option('token_limit' , $token_limit);

and this is how I am accessing it:

 $token_limit = get_option('token_limit');
  • There must be more to your code than the above, as what you are describing doesn't make sense in isolation.
    – vancoder
    Jun 10, 2022 at 15:02

1 Answer 1


I suspect wp-includes/option.php is not being loaded in your environment. You must have the whole WordPress environment loaded to use get_option(). So e.g. per

include_once 'wp-load.php';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.