I am trying to create a dashboard widget using this wp_add_dashboard_widget
hook. I have created a form with some input fields and submit button in it and that is properly appear in widget, but I'm not able to get and save that form fields using update_option
function.
function add_dashboard_widgets() {
wp_add_dashboard_widget('dashboard_widget', 'Upload reports excel sheets', 'dashboard_widget_function');
}
add_action('wp_dashboard_setup', 'add_dashboard_widgets' );
function dashboard_widget_function() {
$rto_status = get_option( 'rto_status', '' );
?>
<form method="POST">
<p><label for="rto_status">RTO Status</label>
<input type="text" id="rto_status" class="jsAddReport" name="rto_status" value="<?php echo ($rto_status) ? $rto_status : ''; ?>" size="60" placeholder="click here to upload RTO Status" /></p>
<input type="submit" name="submit" value="update">
</form>
In this case, I want to save the options on submit button.