16
Mar, 2015
Mar, 2015
Protecting Non-WordPress Content
If you want to use s2Member to protect content that is being loaded outside of WordPress you can do so by including wp-load.php
from the WordPress core files.
<?php
require_once 'wp-load.php';
if(current_user_can('access_s2member_level1'))
{
// User is allowed to view, so display something here.
}
else exit('Permission denied!');
This solution uses PHP code and that means the external pages that use this code will need to be PHP files. Files that end in .htm
or .html
will not be able to use this code unless you've specifically configured your web server to parse those file types with PHP.
See: How To Parse HTML Files As PHP for more information.