• Hi there,

    I want to set the following PHP code of only one of my websites (multisite inbstallation)

    
    if( ( is_shop() || is_single() || is_product() || is_product_category() || is_category() || is_archive() || is_post_type_archive() || is_singular( $post_types = 'page' ) && ! is_front_page() || is_tag() )  && ! is_user_logged_in() ) {
            wp_redirect( site_url( '/' ) );
            exit();
    }

    Sadly doesn’t work. Any idea ?

    Tks

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    You would want to include this code in some sort of template_redirect action hook:

    add_action( 'template_redirect', function () {
    	if ( ( is_shop() || is_single() || is_product() || is_product_category() || is_category() || is_archive() || is_post_type_archive() || is_singular( $post_types = 'page' ) && ! is_front_page() || is_tag() ) && ! is_user_logged_in() ) {
    		wp_redirect( site_url( '/' ) );
    		exit();
    	}
    } );
Viewing 1 replies (of 1 total)
  • The topic ‘Snippet doesn’t work / multisite’ is closed to new replies.