Basically, I need to alter the info the user inputs into an advanced custom fields textbox before it is written to the database but I don't know how to grab it. I can only get it after it has been written to the meta portion of the database by using get_field()
.
1 Answer
Edit - This answer is no longer accurate for the current version of ACF, see their documentation
Use the acf_save_post
hook.
function my_acf_save_post( $post_id )
{
// vars
$fields = false;
// load from post
if( isset($_POST['fields']) )
{
$fields = $_POST['fields'];
}
// ...
}
// run before ACF saves the $_POST['fields'] data
add_action('acf_save_post', 'my_acf_save_post', 1);
// run after ACF saves the $_POST['fields'] data
add_action('acf_save_post', 'my_acf_save_post', 20);
acf/validate_value
filter - see the official documentation.