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

Saving value of a selection option in comment form as comment meta

You can use the function update_user_meta for logged in users and the php function setcookie for the visitors. Here is a start how to work with update_user_meta

You can run this function on submission of the form or by running it by AJAX, i would recommend you to run it with AJAX.

function wpse_update_user_commentform() {

    /**
     * Get values from the selected
     * Dropdown as tha variable $side
     * Change this to your dropdown name
    */

    $side = $_POST['dropdown'];

    $comment_id = get_comment_ID();

    // Update the comment meta "comment_side" to the selected value
    update_comment_meta( $comment_id, 'comment_side', $side );

}

Related Posts:

  1. Save metabox with multiple checkbox array
  2. Ordering posts by metadata
  3. Run Shortcode of post’s custom field in functions.php / Plugin
  4. Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
  5. Any way to update_post_meta with html content? It gets stripped and becomes empty
  6. Displaying Custom Post Meta
  7. How can I add an image upload field directly to a custom write panel?
  8. Post meta vs separate database tables
  9. How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?
  10. How to validate custom fields in custom post type?
  11. How to add tab which is visible only in admin side of product in woocommerce? [closed]
  12. Creating custom field with drop down on new post page
  13. Retrieving custom fields with $wpdb->get_results
  14. How to create Image gallery Metabox in wordpress [closed]
  15. Utilize TinyMCE hyperlink chooser outside of TinyMCE
  16. How to enable users to down-vote in this simple voting counter (that uses the post meta)?
  17. anything like add_meta_box for categories?
  18. template_redirect for single posts w/ custom fields
  19. How can I free up the memory used by update_post_meta?
  20. Is there a way to list tags order by post_meta field
  21. Comment `Reply` link doesn’t work if comments are loaded from ajax
  22. Show comments fields in two columns
  23. Support auto-save and revisions for custom fields
  24. Best choice of options/settings framework for plugin/theme development
  25. Plugin development: get_post_meta is not working [closed]
  26. Act on user meta updated, but only once
  27. Global $post not working in OOP function WordPress
  28. How to check if Woocommerce Order number equals to post ID?
  29. Adding set of custom fields to WordPress Post in Dashboard
  30. update post meta for checkbox in the admin when inserted in the front-end
  31. 403 Error when text is pasted in Custom Metabox Textarea
  32. get_posts() not working when accessing with a custom user role
  33. Custom Taxonomy to dropdown box on adminside wordpress
  34. Create & Save multiple Meta-boxes
  35. Add a Save Button to Custom Meta Box [duplicate]
  36. Plugin with action ‘save_post’ needs to press publish twice on order to publish
  37. Strange issue saving custom field data for a WooCommerce order
  38. Woocommerce – Convert Delivery method into a custom field
  39. Add a default WP comment form to forum template
  40. How to get Metabox custom field to show checked if value is updated using post meta query?
  41. How do I update a field of a meta box?
  42. Input value from metabox is not found in $_POST after post save
  43. Doubts about the use of metadata and how this can affect performance on WordPress
  44. update_post_meta not working in a loop
  45. Get draggable widgets on Edit Post page
  46. Custom code for WordPress dynamic menu
  47. Custom fields for custom post type
  48. Checked() function on a multidimensional array
  49. What is the best way to store a few fields?
  50. Delist entries in the_loop
  51. Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
  52. How can I add a simple custom field to my plugin?
  53. Ajax is not working in a loop
  54. WP nonce field checkbox prints checked=’checked’ outside input field
  55. Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
  56. How to save post meta as an array in Gutenberg?
  57. how to load the comment template from a plugin
  58. per blog metadata for plugin
  59. How to format custom fields when editing an attachment?
  60. Using delete_post_meta for deleting multiple selected options
  61. Get audio metadata on file upload
  62. Plugin can’t be activated [closed]
  63. Remove Meta-boxes (Yoast SEO plugin) [duplicate]
  64. Is there a way to add a link with add_post_meta?
  65. Adjust query on single
  66. how to add custom fields into new & update post page?
  67. Customise Grouped Product display in Woocommerce with custom column
  68. Why is $_POST empty when saving custom Meta Box?
  69. Condition to check previous next article post title
  70. register_meta not showing custom post type metabox data in rest api
  71. WP_Query not ordering correctly
  72. Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
  73. Adding customs fields on each product on the cart
  74. Insert, update or remove data from database (usermeta)
  75. add_meta_box does not display meta box in Admin
  76. Unexpected issue when using attachment_fields_to_edit filter
  77. WordPress delete mysql rows with string
  78. How to get post that has non zero or greater than zero meta value
  79. Saving post meta
  80. How and when would I implement some code which would take data from one part of the Db and put it in another?
  81. Echo out custom fields in comments
  82. Get Commentor IP When Marking Comment As Spam
  83. Include add_post_meta in a plugin
  84. How can i call from custom fields to the category editor?
  85. I want to display the content of a text field only if it has been entered
  86. Create Unique and Customized User ID for Website Members in WordPress
  87. Can I log the searches that are returning 404 in the DB?
  88. A better way of getting draft posts that has a particular post meta using get_posts function
  89. Custom fields in the billing address section woocommerce
  90. Add File field in WooCommerce Box office plugin
  91. Yet another wp_insert_post infinite loop. What is wrong?
  92. Data Validation, dynamically generated fields (select for example)
  93. Initialize class inside plugin
  94. Thumbnails for media Library images
  95. How to Rewrite WordPress URL for a Plugin
  96. Add query string variables to all hyperlinks URL matching a specified domain
  97. WordPress multiple user roles accessing on their information on one site?
  98. loop and in admin header problem
  99. When editing a post with a custom meta box the values aren’t displaying correctly
  100. How do I replace title with my plugin?
Categories plugin-development Tags comment-form, custom-field, plugin-development, post-meta
is_page conditional question
How to make text show up – new page template

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