RSS Enclosures in WordPress Vs Content Protection (YM)

July 31, 2009 | PHP, Time Savers, Tutorials, Wordpress | 0 comments

I have just completed an email exchange with a YM client which lasted around 50 replies and a good month. More down to my hectic schedule than anything else but I, with Googles help, have just solved it.

As you well know I work with Tim Nash over at CNMS and between us we develop and sell the Your Members plugin. The plugin protects blog content based on member levels and then provides the means to pay for access using a variety of methods. </plug>

It’s pretty standard stuff. However… What happens if you want to add some sort of streaming media to the protected section in a blog post?

It doesn’t work is the answer! Ever helpful WordPress scans the post for the presence of certain HTML strings and adds post custom fields if it gets a hit. This is the case for podcasting and flash type plugins. Normally this would be a good thing, however, not when the Object in question is supposed to be protected. A pretty bit security hole in any content protection plugin.

At the most basic level the protection can be restored using the following code…

function delete_enclosure(){
    return '';
}

add_filter( 'get_enclosed', 'delete_enclosure' );
add_filter( 'rss_enclosure', 'delete_enclosure' );
add_filter( 'atom_enclosure', 'delete_enclosure' );

The code should be put into either a new plugin or more simply your functions.php file within your theme. Dead easy!

If you understand it, the code simply picks up on any filters and removes them. Problem solved.  For YM, the next step is not to remove the enlosure if the user should have access. Additionally we don’t want to remove the enclosure if the object is outside of the protected content area. However the function above will suffice for now 🙂

A Donate Button!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

CommentLuv badge

About this site and Sean Barton

Picture of Sean
Sean Barton is a Freelance Website Developer in Crewe, Cheshire. He is a Full Stack Developer but with extensive experience in Wordpress and other Frameworks. He is the Co-Founder of SitePresser, Layouts Cloud and Page Builder Cloud among other things..
This site was set up in 2008 as a tutorial and scripting resource for the PHP language and Wordpress.
Find out more about Sean on the About Me page or use the Hire Me page to get in touch. For more information about Sean's work take a look at the Portfolio

SitePresser is the plugin that packages child themes and layout packs for sale. Works with Divi and Elementor.