Title: get_option returns wrong value
Last modified: October 12, 2022

---

# get_option returns wrong value

 *  [Christopher](https://wordpress.org/support/users/christopherplus/)
 * (@christopherplus)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/get_option-returns-wrong-value/)
 * Hello,
 * I use the plugin in a multisite installation. When the plugin is network activated
   and the object-cache.php file is in place I get the value as `bool(true)` from`
   get_option()` in a subsite instead of `string(1) "1"` as explained here: [https://developer.wordpress.org/reference/functions/get_option/#description](https://developer.wordpress.org/reference/functions/get_option/#description)
 * This create us issues with popular plugins such as Gravity Forms that make the
   following comparison of the returned value:
 * `$returned_value === "1"`

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

 *  Plugin Contributor [Chris Reynolds](https://wordpress.org/support/users/jazzs3quence/)
 * (@jazzs3quence)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/get_option-returns-wrong-value/#post-16383322)
 * [@christopherplus](https://wordpress.org/support/users/christopherplus/) `get_option`
   is a WordPress core function that takes a parameter (the option value). The documentation
   linked indicates that the return value of the `get_option` can be anything as
   it’s context-specific (see [https://developer.wordpress.org/reference/functions/get_option/#return](https://developer.wordpress.org/reference/functions/get_option/#return)).
   Are you saying that when this plugin is installed `get_option()` (no option name
   passed) returns `true` when it should return `"1"` or is there a _specific_ option
   related to the WP Redis plugin that is returning a value that is unexpected (
   and if so, what option name are you requesting)? Or are you saying that all options
   that are true/false are returning boolean values when they should return strings
   when the plugin is installed (but not when it is not)?
 *  Plugin Contributor [Chris Reynolds](https://wordpress.org/support/users/jazzs3quence/)
 * (@jazzs3quence)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get_option-returns-wrong-value/#post-16460420)
 * I’m unable to reproduce this issue.
 * To attempt to reproduce, I installed WP Redis and then created a new `mu-plugin`
   that included an options page. On the options page, I had a radio button that
   included options for `true`, `false`, `'1'`, `'0'`, `'true'`, `'false'`, `1`,`
   0`. I then added a `pre_update_option_{option-name}` hook that explicitly saved
   whatever was stored in my option as a boolean value in a _different_ option.
 * WordPress did not distinguish between `true`, `false`, `1`, `0`, `'1'` or `'0'`.`'
   true'` and `'false'` were correctly interpreted as strings and therefore `true`
   when cast as boolean values no matter which was selected.
 * Whether the plugin was active or not, the results I got always cast a truthy 
   value as `'1'` and a falsey value as `''` (when I explicitly converted to boolean)
   or `'0'` (when I pulled from the stored option).
 * Tested on PHP versions 7.4, 8.0 and 8.2.
 * If anyone sees this and has the same issue, please update this report with specific
   information about your environment, options you are saving, plugins you have 
   installed, etc. so we can dig further into this.

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

The topic ‘get_option returns wrong value’ is closed to new replies.

 * ![](https://ps.w.org/wp-redis/assets/icon-256x256.png?rev=3417699)
 * [WP Redis](https://wordpress.org/plugins/wp-redis/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-redis/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-redis/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-redis/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-redis/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-redis/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Chris Reynolds](https://wordpress.org/support/users/jazzs3quence/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/get_option-returns-wrong-value/#post-16460420)
 * Status: not resolved