Home Forums General Issues Easier way $_POST['acf'] with get_fields($post->ID)


Easier way $_POST['acf'] with get_fields($post->ID)

  • I want to make a function that sends an email with the new content in an updated post. I have found this page and it works great! Thanks for the great documentation.

    I was wondering if there was a easier way to debug these instead of sending the following code via the wp_mail() function. Right now I’m sending these code snippets
    implode(', ', $_POST['acf']); and `implode(‘, ‘, get_fields($post_ID)); to see what is in them, but it would be much easier to see these directly in the browser instead of mailing them to myself each time.

  • The problem with seeing them in the browser is that it will interrupt the process.

    For example, you can output to the browser like this

    echo '$_POST['acf'] = <pre>'; print_r($_POST['acf']); echo '</pre>';
    echo 'get_fields() = <pre>'; print_r(get_fields($post_ID)); echo '</pre>';

    This code will cause a “Headers already sent” error when WP tries to redirect to the admin page after saving. However, for debugging, this is generally what I do. I’m expecting the error and I want to interrupt the process so I can see what’s going on.

    You can also use the debug log. This will output values to the error log and then you can open the log to see what’s in it.

    error_log(implode(', ', $_POST['acf']));
    error_log(implode(', ', get_fields($post_ID));
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.