Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Front end update_post_meta Help

your nonce action name is wrong use same as entered in wp_nonce_field('update_grn_data','grn_data'); and also you forget to echo nonce, try this

if ( isset( $_POST['grn_data'] ) &&  wp_verify_nonce($_POST['grn_data'],'update_grn_data') ) {
    //if nonce check succeeds.
    $postid = $_POST['post_id'];
    $data = $_POST['grn'];
    update_post_meta($postid,'grn',$data);
}

form

<?php
/* This file is to provide input fields to record data from Front End */
function grn_data($post_id) { ?>
    <div class="grndata">
        <label for="grn" id="grnhead">GRN</label>
        <div class="toggle-fedata">
           <?php
           $curgrn = 'grn';
           $grnval = get_post_meta($post_id, $curgrn, true); ?>
           <form method="post" action="">
              <?php echo wp_nonce_field('update_grn_data','grn_data'); ?>
              <input type="text" size="30" maxlength="30" name="<?php echo $curgrn; ?>" value="<?php echo $grnval; ?>" />
              <input type="submit" value="Save" />
              <?php var_dump($grnval); ?>
              <?php var_dump($curgrn); ?>
          </form>
      </div>
   </div>
<?php } ?>

now call the form

echo grn_data($post->ID);

Related Posts:

  1. How to edit a user profile on the front end?
  2. How to display user registration form on front-end of the website?
  3. What is an easy way to display a front-end user registration form?
  4. Autocomplete for taxonomy input boxes on a front end form
  5. Reason action hook won’t work with update_post_meta from frontend form? Alternative?
  6. Built-in data validation function for URLs
  7. How to edit custom user meta information front end
  8. Adding a new user from the front end
  9. Saving frontend form data in wordpress
  10. Validating custom fields before post save
  11. WordPress Frontend Post Form (Bootstrap Modal) Not Creating Post
  12. Headers already sent on a frontend post form using wp_redirect before get_header
  13. wp_nonce for Front-End submission form not working
  14. Post from front end form to post_meta
  15. Update a string from the front-end
  16. Update post meta without deleting the old entries
  17. How to reproduce the post format field in a front end form?
  18. What is &amp used for
  19. How to define form action in JSF?
  20. Free or affordable OCR and ICR (handwriting recognition) SDK?
  21. What characters are allowed in an email address?
  22. How to include landing page with form submission?
  23. Passing error/warning messages from a meta box to “admin_notices”
  24. How to handle form submission?
  25. Add error message on password protected page
  26. Set Featured Image Front Frontend Form
  27. WordPress AJAX File Upload – FrontEnd
  28. Execute action after post is saved with all related post_meta records (data)
  29. update_post_meta and update_field ony working when saving the post
  30. how to set from address according to the form input email address for wp_mail()?
  31. How to get current url in contact form 7
  32. Is wp_nonce_field vulnerable if you know the action name?
  33. How to pass on Google Adwords gclid variable to other pages
  34. using update_user_meta in form to set and get custom meta
  35. Front End Post Save Child terms
  36. Best way to create multi-step form with data saved to user account for later updating?
  37. User registration problem in WordPress
  38. Custom form, shortcode, and submit handler
  39. Let readers suggest edits from the frontend
  40. Creating a contact form without a plugin [closed]
  41. How to submit data from HTML form?
  42. How to link WordPress heartbeat to ajax form
  43. Custom Registration Template/Page
  44. show image in mail contact form 7 [closed]
  45. Get updated meta data after save_post hook
  46. Manipulating post meta in the customizer
  47. Add post meta based on another post meta value before publish post
  48. Can I verify nonce which was generated on a different WP site?
  49. Submitting post to database then redirecting to paypal
  50. Saving two categories from two dropdowns in front end posting form
  51. Get user input from a form
  52. Better post meta efficiency?
  53. Registration form labels – add asterisk
  54. update_post_meta() not working in save_post
  55. How do I save each option in a multiple select menu as it’s own meta_key + meta_value pair?
  56. Sending form data via PHPMailer – How to action PHP script from a form
  57. Up/Down voting system for WordPress
  58. How to create and retrieve data from a special registration form?
  59. Contact form 7 Dynamic text – placeholder on GET field
  60. Settings API erases itself?
  61. how to handle forms in multiple pages?
  62. set_query_var doesn’t seem to work on init hook
  63. update_post_meta for custom field not working upon form submission
  64. How to send multipart form data to WordPress endpoint
  65. need to add attach thumbnail from my form
  66. Post meta checkbox becomes unchecked occasionally
  67. Wp_mail Returning False on Server
  68. recommended practice for form submission
  69. Save attachment custom fields on front end
  70. Placeholders in Jetpack Contact Form [closed]
  71. Metabox of one post influence setting on other
  72. How to update selective options on plugin settings page
  73. $_POST empty on submit (same code, same form submits normally on local server)
  74. Gravity Forms skip form if already filled out using cookie?
  75. Loading scripts & styles from a meta box callback function
  76. Checkbox won’t check when label is clicked
  77. One comment per user per post
  78. Front-End Interfaces Without Shortcodes
  79. Looking for a simple approach for handling user $_POST data without AJAX?
  80. Get updated post meta on save_post action?
  81. update_post_meta not working in save_post
  82. Datepicker not supporting timepicker
  83. Correct processing of `$_POST`, following WordPress Coding Standards
  84. Trying to save and display a wp_editor()
  85. update_post_meta() whenever custom post type is updated
  86. unable to save post meta on single field with multiple selects
  87. Trigger “unsaved changes” dialog for custom post meta changes
  88. How to return variables from admin-post.php
  89. Help with verifying google recaptcha in a custom form
  90. Nonce actions and names available via open source
  91. Setting specific image size for specific form upload file field
  92. Delete post meta conditionally after save post
  93. Frontend posting – everything saves other than checkboxes?
  94. Duplicating/Cloning Multiple Form Fields
  95. Contact forms going into spam folder
  96. Get data from dropdown and update page
  97. Mail Form in a modal box without plugin
  98. Using the WordPress selected() function
  99. Performing a POST action on homepage goes to posts page
  100. Add contact form
Categories forms Tags forms, front-end, post-meta, save-post
Exceprt not displaying
Install old version of plugin from admin panel?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress