How to display the 'settings updated' message
-
Hey all,
I’m trying to get the message that tells a user that some settings have been saved to appear at the top of the screen in a plugin, but I’m having a bit of trouble.
I have the correct code and have placed it in a function –
function write_custom_admin_message($message = null, $class = 'updated'){ if($message === null) return; echo '<div id="message0" class="'.$class.' fade">'; echo '<p><strong>'.$message.'</strong></p>'; echo '</div>'; }
but the problem is that I am having trouble getting my message to the function.
I am using tha action
add_action('admin_post_save_services_options', array(&$this, 'on_save_changes'));
to call the functionon_save_changes()
when the user clicks the ‘Save changes’ button, and I can do all my validation etc in there, but then I don’t know of a way of passing the values for the message box to the main plugin function.function on_save_changes(){ if(!current_user_can('manage_options')) wp_die( __('Cheatin’ uh?')); check_admin_referer('my-admin-referrer'); if(isset($_POST['action']) === true){ $options_name['title'] = $_POST['title']; $options_name['text'] = $_POST['text']; $options_name['image'] = $_POST['image']; update_option('options_name', $options_name); $message = __('Settings saved.'); $class = 'updated'; } wp_redirect($_POST['_wp_http_referer']); }
I hope all that makes sense, and I’d be very greatful if someone could help.
Thanks.
- The topic ‘How to display the 'settings updated' message’ is closed to new replies.