Protected Content Redirect Off

I have set the More Tag to Yes on all my memberships and then i want a user with no account and not logged in to go to a page and see it without getting redirected to Protected Content page

Is there a way to do this?

  • Ash

    Hello @Ben

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    No, this is not possible out of the box, I am afraid. In a single page or post it can't be partially protected. If your pages are not protected, in that case you can show only first paragraph only to the visitors. (without protected content, but some custom code)

    Let me know if you want something like this.

    Cheers
    Ash

  • Ash

    Hello @Ben

    I hope you are well today.

    You can use this simple code:

    add_filter( 'the_content', 'the_content_cb' );
    function the_content_cb( $content ){
    	if( ! is_user_logged_in() ){
    		global $post;
    		if( $post->ID == 1964 ){
    			$content = explode( '</p>', $content );
    			return $content[0];
    		}
    		return $content;
    	}
    	return $content;
    }

    Here 1964 is the page ID you want to show first paragraph only to the visitor.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Also is there a filter for overriding the redirect?

    What do you mean by overriding the redirect? Do you want to disable redirection? Or you want to add something in that protected content page?

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.