I would like to redirect the user to a payment link depending on what choice they make but it's not redirecting. Can anyone see why not please? The strange thing is though; when the post is published, they can edit the form from the frontend and it will then redirect upon saving.
add_filter('acf/save_post', 'stripe_payment_redirect', 20);
function stripe_payment_redirect($post_id) {
$post_id = get_the_ID();
$current_status = get_post_status($post_id);
if (is_admin() || get_post_type($post_id) != 'post_type_listings') :
return;
endif;
if ( have_rows( 'listing_payment_options', $post_id ) ) :
while ( have_rows( 'listing_payment_options', $post_id ) ) :
the_row();
$package_choice = get_sub_field( 'listing_package_options' );
$featured = get_sub_field( 'listing_featured_listing' );
if ( $package_choice == '6 Monthly' && $featured == 1 ) : //'6 Monthly and Featured';
wp_redirect( 'https://buy.stripe.com/test_28o4jW3dGgpTaQwdQV' ); exit;
elseif ( $package_choice == 'Yearly' && $featured == 1 ) : //'12 Monthly and Featured';
wp_redirect( 'https://buy.stripe.com/test_28o3fS15y6Pj7EkbIL' ); exit;
elseif ( $package_choice == 'Yearly' ) : //'12 Monthly Only';
wp_redirect( 'https://buy.stripe.com/test_dR66s415y1uZ5wceUW' ); exit;
else: //'6 Monthly Only';
wp_redirect( 'https://buy.stripe.com/test_14kbMoeWo0qVgaQ5ko' ); exit;
endif;
endwhile;
endif;
}