WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms + Custom Post Types Change post status based on checkbox (1 post)

  1. Sarah_Frantz
    Member
    Posted 1 year ago #

    I'm not sure how to alter the post status based on a check box... I think my hook is getting messed up because of the publish status on the post title field...

    thoughts?

    This is my code

    // where 4 is my form id
    add_filter('gform_post_data_4', 'gform_dynamic_post_status', 10, 4);
    function gform_dynamic_post_status($post_data, $form, $entry) {
    
        // where 17 is my field id
        if($entry[17]) {
        switch($entry[17]) {
            case 'Yes.':
                $post_data['post_status'] = 'pending';
                break;
            case 'No':
                $post_data['post_status'] = 'publish';
                break;
            }
        }
    
        return $post_data;
    }

    But it doens't work. Still keeps publishing to "published" rather than pending for the custom post type

Topic Closed

This topic has been closed to new replies.

About this Topic