I have a successful s2member Pro implementation. Recently I started indexing PDFs to be searchable via Wordpress search. I now find that WP search will display PDFs in the media library to anyone on the website. I need to protect the viewing of PDFs by requiring the user be of membership level 1 or greater. I do not have any download restrictions.
I found this solution that requires users to be logged in, but I need one more level (level 1+). I’m not a php programmer, but I get the gist of what this routine does. Can it, can someone help with modifying it to require a level 1+ s2member role? Is there a better way to accomplish this task?
Thank you! Bob
Open the .htaccess file in the root folder of your WordPress site and edit it with this piece of code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !.wordpress_logged_in.$ [NC]
RewriteCond %{REQUEST_URI} ^(.?/?)wp-content/uploads/. [NC]
RewriteRule . http://%{HTTP_HOST}%1/wp-login.php?redirect_to=%{REQUEST_URI} [L,QSA]
</IfModule>
This will prevent the access to wp-content/uploads to users that are not logged.