Hide Listings from Non-logged in users

This topic contains 2 replies, has 2 voices, and was last updated by  Alex Rollin 4 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #541496

    gowrann
    Expired Member
    Post count: 39

    HI,

    What’s the best way to hide all listings from any users not logged in? (including from any search results from default WordPress search function)

    THanks

    #541497

    gowrann
    Expired Member
    Post count: 39

    This seems to do it…

    
    	add_action( 'init', 'tr_hide_custom_type_search', 99999 );
    
    	function tr_hide_custom_type_search() {
    		global $wp_post_types;
    
    		if ( post_type_exists( 'gd_place' ) ) {
    
    			// exclude from search results
    			$wp_post_types['gd_place']->exclude_from_search = true;
    		}
    	}
    
    #541510

    Alex Rollin
    Moderator
    Post count: 27815

    Thanks for sharing, glad you found a solution.

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount