Support

Account

Home Forums General Issues Redirect Based on ACF Value

Unread

Redirect Based on ACF Value

  • This snippet of code just won’t work for us. It’s supposed to look at the post type, and if it is our custom type, make sure we’re not actually editing a post, then redirect if an ACF field is not ticked. No joy. Any help would be much appreciated!

    $post_type = get_post_type( $post->ID );
    if ($post_type == "our_product") {
    
            // We're not editing the product because saving it would redirect!
            global $pagenow;
            if ($pagenow != 'post.php') {   
        
                // Is this a product landing page?
                $isproductlanding = get_field('is_product_landing_page', $post_id);
                    if($isproductlanding != "1") {
        
                        header("Location: http://ourhomepage.com/");
                        exit;
        
                }
            }
        }
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.