Comments on: ACF validate_value Filter With post_ID https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/?utm_source=rss&utm_medium=rss&utm_campaign=advanced-custom-fields-validate_value-filter-with-post_id Technology, Travel, and Pictures Tue, 07 Jun 2022 02:32:38 +0000 hourly 1 https://wordpress.org/?v=6.0.1 By: Doug https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-2730 Tue, 07 Jun 2022 02:32:38 +0000 http://justinsilver.com/?p=3769#comment-2730 This is no longer needed. You can access it through either $_POST[‘post_id’] for post types or $_POST[‘_acf_post_id’] on options pages.

]]>
By: Don https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-2701 Sat, 09 May 2020 17:24:01 +0000 http://justinsilver.com/?p=3769#comment-2701 I know this is an old post, but it’s still a relevant need even now. I didn’t like the proposed solution, so I set out to find an alternative. My solution is a lot simpler – the post_id is POSTed upon submit, and accessible during validation. Simple reference $_POST[‘post_id’] to access the post_id. No need to create hidden fields to pass what’s already being passed.

]]>
By: Justin Silver https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-2204 Tue, 12 Jul 2016 17:55:22 +0000 http://justinsilver.com/?p=3769#comment-2204 In reply to Michael.

Sorry, just saw this comment – I double checked the syntax and it looks correct to me. You could try moving lines 6-9 to one line (I formatted it that way to make it easier to read). Also make sure that none of the quotation marks are being translated into something fancy.

]]>
By: Justin Silver https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-2203 Tue, 12 Jul 2016 17:53:16 +0000 http://justinsilver.com/?p=3769#comment-2203 In reply to Michael.

Hi Michael – which command are you running when you get that error? It’s important that everything be copied exactly you you may run into syntax errors. Good luck!

]]>
By: Michael https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-2193 Fri, 01 Jul 2016 02:22:42 +0000 http://justinsilver.com/?p=3769#comment-2193 In reply to Michael.

This was on line 7 MY_ACF_FORM_VALUES,

]]>
By: Michael https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-2192 Fri, 01 Jul 2016 02:21:32 +0000 http://justinsilver.com/?p=3769#comment-2192 Im getting error
syntax error, unexpected ‘,’

]]>
By: Justin Silver https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-1965 Tue, 06 Oct 2015 18:09:11 +0000 http://justinsilver.com/?p=3769#comment-1965 In reply to Jamie.

Good call on not needing is_admin() – I copied this from Validated Field which does some other things that do require the admin check. Since I wrote this post I realized it’s probably prudent to use something like acf[my_unique_sub_array][post_id] or similar to prevent conflicts with ACF should you ever have a field named post_ID. A lot of new features being added in version 2.0 if you care to check it out: https://github.com/doublesharp/validated-field-for-acf

]]>
By: Jamie https://www.justinsilver.com/technology/wordpress/advanced-custom-fields-validate_value-filter-with-post_id/#comment-1964 Sun, 04 Oct 2015 10:02:20 +0000 http://justinsilver.com/?p=3769#comment-1964 Fantastic contribution! The post ID should be in the validate hook but this is a perfect workaround

The conditional is_admin() is not required, since edit_form_after_editor only fires in the editor anyway
https://github.com/WordPress/WordPress/blob/master/wp-admin/edit-form-advanced.php#L653

]]>