Support

Account

Home Forums General Issues Hook/Filter to edit the timestamp after user has selected a date and time Reply To: Hook/Filter to edit the timestamp after user has selected a date and time

  • Update:


    @jonathan
    in my DB ACF is saving the datetime as a UNIX timestamp. I have edited the code to use update_field() and it still isn’t saving to the database, using the field name or field key.

    function updateSeminarTime($post_id)
    {
    
        // bail early if no ACF data
        if (empty($_POST['acf'])) {
    
            return;
    
        }
    
        // array of field values
        //$fields = $_POST['acf'];
    
        // specific field value
        $post = get_post($post_id);
        $expertId = $post->post_author;
        $userTimeZone = getTimeZone($expertId);
        $userTimeZoneOffset = get_timezone_offset($userTimeZone, 'UTC');
        $seminarDate = $_POST['acf']['seminar_date'];
        $seminarDate = strtotime($seminarDate);
        $seminarDate = $seminarDate + $userTimeZoneOffset;
        //$seminarDate = date('m/d/y h:mm tt', $seminarDate);
        echo $seminarDate;
        echo $userTimeZoneOffset;
        echo $post_id;
        update_field('field_552cb019acd87',$seminarDate,$post_id);
    }
    
    // run before ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'updateSeminarTime', 20);

    When I save the post, it automatically takes me to the new post. How can I debug this and see any echo’d values etc?