WPPizza – A Restaurant Plugin for WordPress › Support › General Support › update_option from a custom admin page
- AuthorPosts
- 12 September, 2016 at 5:52 pm #21621
Hi,
I’m trying to update order_email_to from a custom admin page. But no way.
I created a new plugin to add an admin page with add_menu_pagefunction test_plugin_setup_menu(){ add_menu_page( 'Email', 'Email', 'contributor', 'test-plugin', 'test_init' ); } add_action('admin_menu', 'test_plugin_setup_menu'); function test_init(){ save_my_email(); } function save_my_email(){ $options=get_option('wppizza'); echo 'MY EMAIL '.$options['order']['order_email_to'][0]; $options['order']['order_email_to'][0]='[email protected]'; $go=update_option('wppizza', $options); if($go==false){ echo 'false'; }else{ echo 'yes'; } } //If I do save_my_email() outside test_init(), it's ok. //save_my_email()
But the result is always FALSE, the option isn’t saved. Impossible to solved this problem.
Why … What’s wrong ?
Thanks
Nicolas12 September, 2016 at 6:40 pm #21624ignoring the fact that i don’t understand why you would actually need this if there is a perfectly good admin page that lets you set the email address
$go
will only return true if the option was actually updated (that is CHANGED)
if you keep setting the same email address, it will only ever be true the first time you set it12 September, 2016 at 6:44 pm #21625generally speaking though, debugging your scripts is somewhat outside plugin support….
for this sort of thing, i would suggest something like
http://wordpress.stackexchange.com/(or of course https://developer.wordpress.org/reference/)
12 September, 2016 at 6:47 pm #21626Ok I understand.
Thank you - AuthorPosts
- The topic ‘update_option from a custom admin page’ is closed to new replies.