Home › Forums › ACF PRO › Get Post ID of post where acf_form is embedded within acf/validate_value › Reply To: Get Post ID of post where acf_form is embedded within acf/validate_value
Are you trying to get this when the form is shown or during validation?
If it is in validation (based on the title of the OP) then there will be no way to get the post ID of the page the form is embedded on unless you provide that information.
There are a couple of methods you can use to do this.
1) Probably the method I would use would be to use either the html_before_fields or html_after_fields argument of wp_form() to add html that includes a hidden field in the form and populate that hidden field with the get_queried_object_id();
2) Create a field in acf for the current post ID. Use an acf/prepare_field filter to populate the field with the current post ID and to hide the field.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.