WordPress.org

Ready to get started?Download WordPress

Forums

Members
[resolved] Restrict Access to Posts Page (12 posts)

  1. mattpnolan
    Member
    Posted 10 months ago #

    I used this method to create a static front/home page for my site as well as a separate Posts page: http://en.support.wordpress.com/pages/front-page/

    I did this, because I want to restrict the ENTIRE Posts page to only users in a certain "member" group.

    However, it does not appear to be working. Even though I restricted the access to the Posts page using the Members-plugin settings on that page, all users are able to see that page without any issue.

    I'm guessing this is because the Posts show up on the page via a different method than just publishing content on a page. However, if at all possible, I'd like to show a completely blank page (or page with custom message) instead of showing my posts (i.e. I don't even want to show post titles to people not in the correct member group).

    Does anyone know how I can fix this? Thank you!

    http://wordpress.org/plugins/members/

  2. mattpnolan
    Member
    Posted 10 months ago #

    What would work even better is if I could redirect anyone with a "Subscriber" role to one page...and no matter what other page they tried to access, they would just keep getting redirected to the one page that I created with a message to members not yet approved to see any other content...

  3. mattpnolan
    Member
    Posted 9 months ago #

    This was resolved on the Theme Hybrid forum with a custom plugin.

  4. alwaysbrightblue
    Member
    Posted 9 months ago #

    Can you post a link to the solution on the Theme Hybrid forum?

  5. mattpnolan
    Member
    Posted 9 months ago #

  6. blips
    Member
    Posted 8 months ago #

    Can you post the solution? $29 for one answer is to much!
    Thanks

  7. alwaysbrightblue
    Member
    Posted 8 months ago #

    ^blips - yep, thats what I thought.

  8. mattpnolan
    Member
    Posted 8 months ago #

    Sure. Here is some sample code:

    add_action( 'template_redirect', 'my_redirect' );
    
    function my_redirect() {
    
    	if ( current_user_can( 'subscriber' ) || !is_user_logged_in() ) {
    
    		if ( is_home() || is_front_page())
    			wp_redirect( 'http://example.com/gohere' );
    	}
    }
  9. shmagic
    Member
    Posted 7 months ago #

    Hi, I have the exact same problem
    Where do I put the code ?

    I try adding it in the membership plugin php, it seemed to do the trick but then it redirected from all the pages (accept the register page) and I wan't it to redirect ONLY from the post page (so the other pages will work as usuall)

    thanks

  10. alwaysbrightblue
    Member
    Posted 7 months ago #

    You could try adding a function in functions.php in your child theme. If you continue to modify the plugin, you might lose the changes if the plugin is updated.

    You can look at focusing this to a post type. (http://codex.wordpress.org/Post_Types)

    I quickly googled for something, and you can try getting more specific with post types, too using something like:

    if (is_archive()) // if displaying any archive
    elseif (is_page()) // if displaying a wp Page (write -> page)
    elseif (is_single()) // if displaying single post
    else // everything else
  11. shmagic
    Member
    Posted 7 months ago #

    I just want the static post page to be restricted, just that
    it seems weird that there's not plugin that can do that

  12. Shaun Scovil
    Member
    Posted 1 month ago #

    Here is a function you can add to your theme's functions.php file, which is a bit more efficient than doing a redirect: https://gist.github.com/sscovil/535de15f134be519f6e4

    Create a page called "Login" (or whatever) using the [wp-members page="login"] shortcode, grab the ID of that page, then pop it into the function on the line that reads:

    $query->set( 'page_id', '12' );

    Replace the number '12' with your login page ID and non-members (or members who aren't logged in) will see the login page instead of the post index.

    This function uses the pre_get_posts action hook to modify the WP_Query object.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.