• Hi does anybody knows how to let register users see the private posts without plugins that can help me.
    cause i know only admin and editors i think can see these posts and i want to make them visible for all register users any help is greatly appreciated. Thank you in advanced

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @oliverosm,

    Apply this code in your functions.php file :

      // 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 );

    Regards

    Thread Starter oliverosM

    (@oliverosm)

    Thank you for taking the time to share such a valuable information, your code worked 100% thanks again.

    If anyone is having the same issue these is the answer.

    • This reply was modified 8 years, 4 months ago by oliverosM.

    Hello @oliverosm,

    Glad that it worked for you.

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Private posts for registered users (subscriber)’ is closed to new replies.