I’m trying to create a settings page for my WordPress plugin, and the update_option() method isn’t working as expected.
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tt = $_POST['theme_title'];
echo $tt;
update_option('theme_title', $tt);
}
Using the code above, if I submit the form with a new value for theme_title
, the page prints out the new value. update_option()
even returns “1”. But the new value isn’t saved in the database.
However, replacing with update_option('theme_title', 'test')
results in the value “test” being saved in the database.
How is it possible that the method only accepts an explicit string and not a variable?