Avinash Gupta
Avinash Gupta

Reputation: 328

save form value in post_meta wordpress

function yummy_sounds_custom(){
    add_menu_page( 
        __( 'Custom Menu Title', 'textdomain' ),
        'Licence',
        'manage_options',
        'licence',
        'licence_fields',
        '',
        6
    ); 
}

add_action( 'admin_menu', 'yummy_sounds_custom' );



/**

 * Display a custom menu page

 */
function licence_fields() {
    ?>
    <h2>Fill the licence details</h2>

    <form method="post" action="">
    <div>Licence Title :</br> <input type="text" name="title" /></div>
    <div>Licence Tagline :</br> <input type="text" name="tagline" /></div>
    <div>Price :</br> <input type="text" name="price" /></div>
    <div>Currency Symbol :</br> <input type="text" name="symbol" /></div>
    <div>Description :</br> <textarea rows="7" cols="50" name="description"></textarea></div>
    <div><input type="submit" value="Submit" name="submit"></div>
    </form>

I am new for customization of wordpress so i have no idea how to save data in wordpress table .I am creating this form in custom admin menu and want to save data in post_meta how i can do it any help

Thanks in advance

Upvotes: 0

Views: 889

Answers (2)

Jędrzej Skrzypczak
Jędrzej Skrzypczak

Reputation: 138

You could involve Wordpress Ajax functionality for this: Wordpress Codex.

Save data with update_option and read it with get_option functions. This is scenerio for single license.

If you like to create collection of licenses, just like posts for example, you must create new custom post type. Then you will have post id in new post type, and you could use update_post_meta and get_post_meta.

Upvotes: 1

Obzi
Obzi

Reputation: 2390

post_meta's datas are linked to a specific post, if you want to save global data you need to use update_option and get_option.

Upvotes: 0

Related Questions