Submit button not saving settings
-
Hello, I have coded a plugin to have its own menu page for my client. the point of the plugin is so they can go in and update the time and location of where their food truck is goin to be. when i put in the info and press submit it erases all the fields i entered. i cant figure out what i am doing wrong.. is it in the function call back?
Below is my code:
<?php /* Plugin Name: THE SHISH SCHEDULE Plugin URI: https://www.peterartmont.com/thebigshish Description: This widget will let you update where you will be for the week and where u will be in the afternoon and evening. Version: The Plugin's Version Number, e.g.: 1.0 Author: Peter Artmont Author URI: https://wwww.peterartmont.com License: THE SHISH SCHEDULE */ add_action( 'admin_menu', 'my_admin_menu' ); function my_admin_menu() { add_menu_page( '7 Day Schedule', '7 Day Schedule', 'manage_options', 'shish7dayplugin', 'schedule_page', '/THEBIGSHISH/blog/wp-content/plugins/BigShish7DaySchedule/Calendar-icon.png', '3' ); } add_action( 'admin_init', 'my_admin_init' ); function my_admin_init() { register_setting( '7dayschedule-group', '7dayschedule-settings' ); add_settings_section( 'monday', 'Monday', 'monday_callback', 'shish7dayplugin' ); add_settings_field( 'field-one', 'Monday Afternoon Time', 'field_one_callback', 'shish7dayplugin', 'monday' ); add_settings_field( 'field-two', 'Monday Afternoon Location', 'field_two_callback', 'shish7dayplugin', 'monday' ); add_settings_field( 'field-three', 'Monday Evening Time', 'field_three_callback', 'shish7dayplugin', 'monday' ); add_settings_field( 'field-four', 'Monday Evening Location', 'field_four_callback', 'shish7dayplugin', 'monday' ); add_settings_section( 'tuesday', 'Tuesday', 'tuesday_callback', 'shish7dayplugin' ); add_settings_field( 'tuesday_field-one', 'Tuesday Afternoon Time', 'tuesday_field_one_callback', 'shish7dayplugin', 'tuesday' ); add_settings_field( 'tuesday_field-two', 'Tuesday Afternoon Location', 'tuesday_field_two_callback', 'shish7dayplugin', 'tuesday' ); add_settings_field( 'tuesday_field-three', 'Tuesday Evening Time', 'tuesday_field_three_callback', 'shish7dayplugin', 'tuesday' ); add_settings_field( 'tuesday_field-four', 'Tuesday Evening Location', 'tuesday_field_four_callback', 'shish7dayplugin', 'tuesday' ); add_settings_section( 'wednesday', 'Wednesday', 'wednesday_callback', 'shish7dayplugin' ); add_settings_field( 'wednesday_field-one', 'Wednesday Afternoon Time', 'wednesday_field_one_callback', 'shish7dayplugin', 'wednesday' ); add_settings_field( 'wednesday_field-two', 'Wednesday Afternoon Location', 'wednesday_field_two_callback', 'shish7dayplugin', 'wednesday' ); add_settings_field( 'wednesday_field-three', 'Wednesday Evening Time', 'wednesday_field_three_callback', 'shish7dayplugin', 'wednesday' ); add_settings_field( 'wednesday_field-four', 'Wednesday Evening Location', 'wednesday_field_four_callback', 'shish7dayplugin', 'wednesday' ); add_settings_section( 'thursday', 'Thursday', 'wednesday_callback', 'shish7dayplugin' ); add_settings_field( 'thursday_field-one', 'Thursday Afternoon Time', 'thursday_field_one_callback', 'shish7dayplugin', 'thursday' ); add_settings_field( 'thursday_field-two', 'Thursday Afternoon Location', 'thursday_field_two_callback', 'shish7dayplugin', 'thursday' ); add_settings_field( 'thursday_field-three', 'Thursday Evening Time', 'thursday_field_three_callback', 'shish7dayplugin', 'thursday' ); add_settings_field( 'thursday_field-four', 'Thursday Evening Location', 'thursday_field_four_callback', 'shish7dayplugin', 'thursday' ); add_settings_section( 'friday', 'Friday', 'friday_callback', 'shish7dayplugin' ); add_settings_field( 'friday_field-one', 'Friday Afternoon Time', 'friday_field_one_callback', 'shish7dayplugin', 'friday' ); add_settings_field( 'friday_field-two', 'Friday Afternoon Location', 'friday_field_two_callback', 'shish7dayplugin', 'friday' ); add_settings_field( 'friday_field-three', 'Friday Evening Time', 'friday_field_three_callback', 'shish7dayplugin', 'friday' ); add_settings_field( 'friday_field-four', 'Friday Evening Location', 'friday_field_four_callback', 'shish7dayplugin', 'friday' ); add_settings_section( 'saturday', 'Saturday', 'saturday_callback', 'shish7dayplugin' ); add_settings_field( 'saturday_field-one', 'Saturday Afternoon Time', 'saturday_field_one_callback', 'shish7dayplugin', 'saturday' ); add_settings_field( 'saturday_field-two', 'Saturday Afternoon Location', 'saturday_field_two_callback', 'shish7dayplugin', 'saturday' ); add_settings_field( 'saturday_field-three', 'Saturday Evening Time', 'saturday_field_three_callback', 'shish7dayplugin', 'saturday' ); add_settings_field( 'saturday_field-four', 'Saturday Evening Location', 'saturday_field_four_callback', 'shish7dayplugin', 'saturday' ); add_settings_section( 'sunday', 'Sunday', 'sunday_callback', 'shish7dayplugin' ); add_settings_field( 'sunday_field-one', 'Sunday Afternoon Time', 'sunday_field_one_callback', 'shish7dayplugin', 'sunday' ); add_settings_field( 'sunday_field-two', 'Sunday Afternoon Location', 'sunday_field_two_callback', 'shish7dayplugin', 'sunday' ); add_settings_field( 'sunday_field-three', 'Sunday Evening Time', 'sunday_field_three_callback', 'shish7dayplugin', 'sunday' ); add_settings_field( 'sunday_field-four', 'Sunday Evening Location', 'sunday_field_four_callback', 'shish7dayplugin', 'sunday' ); } function monday_callback() { echo 'This is where Your times for Monday go.'; } function tuesday_callback() { echo 'This is where Your times for Tuesday go.'; } function wednesday_callback() { echo 'This is where Your times for Wednesday go.'; } function thursday_callback() { echo 'This is where Your times for Thursday go.'; } function friday_callback() { echo 'This is where Your times for Thursday go.'; } function saturday_callback() { echo 'This is where Your times for Thursday go.'; } function sunday_callback() { echo 'This is where Your times for Thursday go.'; } function field_one_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function field_two_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function field_three_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function field_four_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function tuesday_field_one_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function tuesday_field_two_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function tuesday_field_three_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function tuesday_field_four_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function wednesday_field_one_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function wednesday_field_two_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function wednesday_field_three_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function wednesday_field_four_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function thursday_field_one_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function thursday_field_two_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function thursday_field_three_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function thursday_field_four_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function friday_field_one_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function friday_field_two_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function friday_field_three_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function friday_field_four_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function saturday_field_one_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function saturday_field_two_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function saturday_field_three_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function saturday_field_four_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function sunday_field_one_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function sunday_field_two_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function sunday_field_three_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function sunday_field_four_callback() { $setting = esc_attr( get_option( '7dayschedule-settings' ) ); echo "<input type='text' name='my-setting' value='$setting' />"; } function schedule_page() { ?> <div class="wrap"> <h2>7 Day Schedule</h2> <form action="options.php" method="POST"> <?php settings_fields( '7dayschedule-group' ); ?> <?php do_settings_sections( 'shish7dayplugin' ); ?> <?php submit_button('Save 7 Day Schedule','primary'); ?> </form> </div> <?php
[Please not that backticks and single quotes are not the same thing]finally i was hoping to be able to access the information they enter into the settings fields and i would be able to input that into a custom css calendar page i make them.
any pointers on how to go about this. I am very beginner to wordpress codex.
- The topic ‘Submit button not saving settings’ is closed to new replies.