Created
September 11, 2013 15:24
-
-
Save guillermorangel/6525209 to your computer and use it in GitHub Desktop.
allow subscriber user roles to view private pages and posts
http://cms.about.com/od/advanced/a/How-To-Let-Subscribers-View-Your-Private-Wordpress-Blog.htm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Allow subscribers to see Private posts and pages | |
$subRole = get_role( 'subscriber' ); | |
$subRole->add_cap( 'read_private_posts' ); | |
$subRole->add_cap( 'read_private_pages' ); | |
// Redirect to home page on login | |
function loginRedirect( $redirect_to, $request_redirect_to, $user ) { | |
if ( is_a( $user, 'WP_User' ) && $user->has_cap( 'edit_posts' ) === false ) { | |
return get_bloginfo( 'siteurl' ); | |
} | |
return $redirect_to; } | |
add_filter( 'login_redirect', 'loginRedirect', 10, 3 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment