• Resolved PZ5413

    (@pz5413)


    Hey everyone,

    I have a site that forces user registration when they browse away from certain pages. This is great for our security purposes, but is giving me issues when trying to run my feed through feedburner.

    The link to my feed works fine:
    http://www.ourbestassociates.com/feed/?post_type=corenews

    However, when I try to insert that link at feedburner and get my feed going, the website redirects them to the registration page, which then in turn results in an error from Feedburner, telling me the page is a webpage, not a feed page.

    No duh. So, here is the code which excludes certain pages, but is there a way to exclude the feed link as well?

    if( !function_exists('forceRegistration') ) :
    	function forceRegistration() {
    		if( !is_user_logged_in() ) :
    			if( !is_page(12) && !is_page(14) && !is_page(115) && !is_page(40) && !is_page(139) ) :
    				header("HTTP/1.1 302 Temporary Redirect");
    				header("Location:" . get_permalink(115) );
    				exit();
    			endif;
    		endif;
    	}
    
    	add_action('template_redirect', 'forceRegistration');
    endif;
Viewing 1 replies (of 1 total)
  • Thread Starter PZ5413

    (@pz5413)

    I have figured it out in case anyone else comes across this issue… WordPress has a conditional statement called “is_feed()”… just added that in like so:

    if( !function_exists('forceRegistration') ) :
    	function forceRegistration() {
    		if( !is_user_logged_in() ) :
    			if( !is_page(12) && !is_page(14) && !is_page(115) && !is_page(40) && !is_page(139) && !is_feed() ) :
    				header("HTTP/1.1 302 Temporary Redirect");
    				header("Location:" . get_permalink(115) );
    				exit();
    			endif;
    		endif;
    	}
    
    	add_action('template_redirect', 'forceRegistration');
    endif;

    and the site now allows anyone not logged in to access the feed as well 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude Feed from Redirect List’ is closed to new replies.