0

I'm developing a private site for a customer (only accesible by loggin in) and I would like to make the RSS feed only accesible by MailChimp.

I know how to take the feed out of the auth_redirect and is_user_logged_in function, but I don't know how to make that specific URL only accesible by MailChimp (if there's a way)

  • What about creating a new feed with a "secret" slug and give that to MailChimp ? – birgire Feb 5 '18 at 13:00
  • It's a possibility, but it would be open to everyone else as well. If there is no way to limit the access to mailchimp, I will sure use your idea!! – Enzo Feb 5 '18 at 13:06
  • Going more specific than that would require details on MailChimp setup/fetching API. For example if MailChimp supports http authorization or other kind of auth with e.g. rest api, xml-rpc etc. – birgire Feb 5 '18 at 13:13
  • They just fetch the data via RSS, that's why I thought that limiting the access to /feed/ from certain URL would be enough. But I just can't figure out how to do that. – Enzo Feb 5 '18 at 14:09
  • use a public RSS feed with MailChimp. says here in the MailChimp's KB. – birgire Feb 5 '18 at 15:22
2

Finally, the solution has been, as birgire pointed out, creating a custom feed and only allowing access to that URL:

// Create new feed
add_action('init', 'customRSS');
function customRSS(){
    add_feed('supersecretfeed', 'customRSSFunc');
}

function customRSSFunc(){
    get_template_part('rss', 'supersecretfeed');
}

Then, as the site is private, I had to allow public access to that specific URL, adding the is_feed option:

// Ban non logged users
function protect_whole_site() {
    if(! is_page( 'wp-login.php' ) && ! is_feed('supersecretfeed') && ! is_user_logged_in() ) {
        auth_redirect(); 
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.