I am creating a wp site for a sports team. On the main dashboard, I want to create a simple widget that will allow the admins to update the team's record. Then on a page template, I would like to echo out that content.
I COULD add custom fields using ACF to the page editor for the page in question, but I would like to get this on the dashboard for more visibility.
Here is what I have so far, I can get the form to show up, but I can't submit it to the db to store the data. In my functions.php (will move to site specific plug in later). Mainly my problems lie in the form action, and in the $control_callback
// Function that outputs the contents of the dashboard widget
function dashboard_widget_function( $post, $callback_args ) {
echo '<form id="record" method="POST" action="//Should this point to a function or endpoint?"><input type="text" name="wins" id="wins" placeholder="wins">'
.'<input type="text" name="losses" id="losses" placeholder="losses"><input type="submit" value="update"></form>';
}
function dashboard_widget_submit( $post, $callback_args ){
//No idea what to do here
}
// Function used in the action hook
function add_dashboard_widgets() {
wp_add_dashboard_widget('dashboard_widget', 'Stars Record', 'dashboard_widget_function', 'dashboard_widget_submit');
}
// Register the new dashboard widget with the 'wp_dashboard_setup' action
add_action('wp_dashboard_setup', 'add_dashboard_widgets' );