add_action('gform_after_submission_33', 'customize_submission_values_for_custom_post_type', 10, 2);
function customize_submission_values_for_custom_post_type($entry, $form) {
    if ($form['id'] !=  33) return;

    $post_id = rgar($entry, 'post_id');

    // Debugging: Check if post_id is set
    if (!$post_id) {
        error_log('Post ID is not set');

    $field_95_value = rgar($entry, '95');
    $field_35_value = rgar($entry, '35');
    $sp_title_value = !empty($field_95_value) ? $field_95_value : $field_35_value;

    if (!$sp_title_value) {
        error_log('sp_title_value is not set');

    // Update the custom field
    $result = update_post_meta($post_id, 'sp_title', $sp_title_value);

    if (!$result) {
        error_log('Failed to update sp_title');

I am getting error Post ID is not set.. I am trying to update a custom field in a custom post type. Using the Post Creation plugin for Gravity Forms.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.