How to retrieve form data?

Question

I want to save the value of input data and retrieve it.
I’m new to creating WordPress plugin and I don’t know how to get the value from the form. I have seen some plugin development tutorials but I’m unable to develop it properly.
Here is my code:

/*
Plugin Name:  My Custorm Form
Plugin URI:   https://abcd.com
Description:  New plugin
Version:      0.1
Author:       RB
*/

function my_plugin_settings()
{
    add_menu_page( 'My Plugin',
                    'myCust Form',
                    'administrator',
                    'insert-my-plugin_bro',
                    'my_plugin_settings_page',
                    'dashicons-translation',
                    '60'
                );  
}
add_action('admin_menu', 'my_plugin_settings');


function my_plugin_options()
{
    register_setting('my-form-group','user_input_name');
}
add_action('admin_init', 'my_plugin_options');


function my_plugin_settings_page()
{
    echo "<h1>My Plugin Settings</h1>";
    ?>
    <div class="wrap">
        <form  action="options.php" method="post">
        <?php settings_fields('my-form-group'); ?>
            <b>Enter a name to display:</b><br/>
            <input type="text" name="default-image-url" value="" >

            <?php submit_button(); ?>
        </form>
    </div>
    <?php
}
?>
0
RajB009 6 years 2017-11-28T11:25:41-05:00 0 Answers 86 views 0

Leave an answer

Browse
Browse