Tuesday, 31 January 2023

Save One field data in option table.

 add_action('admin_menu','admin_menu_adding');

add_action('admin_init','admin_reg_settings');


function admin_menu_adding(){

    add_menu_page('Phone Number','Phone Number','administrator','mega-page','settings_page_test');

}


function settings_page_test(){

$phonenumber = get_option('phonenumber');

    ?>

<div class="wrap">

            <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>

    <form method="post" action="<?php echo admin_url('options.php'); ?>">

        <?php

        settings_fields('local-settings');

        do_settings_sections('local-settings');

        ?>

<input type="text" name="phonenumber" value="<?php echo $phonenumber; ?>" />

        <?php submit_button(); ?>

    </form>

</div>

    <?php

}


add_action('admin_action_trotbgo','save_value_here');


function save_value_here(){

    update_option();

    exit;

}


function admin_reg_settings(){

    register_setting('local-settings','phonenumber');

}

No comments:

Post a Comment