0

Current code

function gravity_form_submitted($entry) //, $form)
{
if(is_user_logged_in()){
    $user_id = get_current_user_id();
} else {
    //session_start();
    $user_id = $_SESSION['new_user_id'];
}

$priority = rgar( $entry, 42 ); //gform field_id referring to priority
$tokens_purchased = explode('|', rgar( $entry, 43)); //gform field_id 
referring to item purchased (product_id from woocommerce)
$coupon = rgar($entry, 45);

$token = new Tokens();

if($tokens_purchased[0] !== 'account'){
    $order = new Order();
    $order_id = $order->newOrder($user_id, $tokens_purchased[0], $coupon);
    $token->addTokens($order_id);
}

$token->removeTokens($user_id, $priority);

$arg = array(
    'ID' => $_SESSION['new_post_id'],
    'post_author' => $user_id,
);
wp_update_post( $arg );

//Clear session
unset($_SESSION['new_post_id'], $_SESSION['new_user_id']);
}
add_action('gform_after_submission', 'gravity_form_submitted', 10, 2);

I tried using the gform_is_value_match to exclude a certain post from the woocommerce order creation but I can't find the hook to exclude post ID

Does anyone know how to exclude post ID from order creation?

0

Try this :

add_action( 'gform_after_submission', 'gravity_form_submitted', 10, 2 );

function gravity_form_submitted($entry, $form)
{
  if($form['id'] != "exclude_form_id")//if multiple you can check not in array
     { 
        //your order generation code
     }
}

Form Object $form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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