A plugin shortcode displays a form underneath each post. Within the form thus displayed, there are numerous visible fields to be filled by users. There is also a hidden field to update a meta key visible on the back end only, with a place for value - as in image. I want to secretly pass the ID of the post (or title or name or slug etc) under which the form (by shortcode) is appearing, so I know at least where the form was even filled from.
Please consider modulating your solution so it can be understood by a beginner. (My question history shows)
I've tried a number of ways of using $post
variable for the last 20 days - assuming its super global, using hooks, but a new session when submitting the form means I couldn't access the post data... either in functions.php
file or the plugin PHP files - likewise sending data through PHP POST method seems like over exertion (it also places an extra submit button).
Im so lost for direction now!
I have access to $post
in the Loop, on the individual post displayed - but I want any of the post attributes (ID/title/slug etc) to automatically STUFF into that one field when someone hits submit !!!?
Note: since $post
is inaccessible, none of these work when directly placed in the value field: $post->ID
$post->ID
post_id
$postid
$post_id
{$postid}
{$post_id}
the_ID
ID
get_the_ID();
the_title();
get_queried_object_id()
replaceme
and using jQuery replace the value. That way at least visitors with JS enabled will submit with whichever post info you want. Or alternatively, you could set up Google Tag Manager to capture form submissions as a Google Analytics Event and capture the page URL they came from.