1

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

1 Answer 1

1

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);
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.