• DeveWeb

    (@deveweb)


    hi guys, I have a litle problem, i need restrict subscriber user to a specific page, example: post-product.php I need to restrict that page, just have access to the authors, administrators, except subscribers, some code that I can add to post-product.php or in functions.php.?

    Really thanks in advanced for the help someone can give me.!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    It may be easiest to make the page private. Authors normally will not be able to read private pages, but they could be granted this capability if it does not conflict with your existing role scheme. This can be done by running add_cap() one time to modify the DB. The code can be removed after this is done.

    Or you may wish to use a plugin such as Members for complete flexibility in managing roles and capabilities.

    There is also a coding solution if need be by using a conditional on the page template along these lines:

    if(current_user_can('upload_files')) {
       // normal page content goes here
    } else {
       echo 'You do not have adequate capabilities to view this page.';
    }

    I choose the upload_files capability, but it can be any capability that subscribers lack and all others have.

Viewing 1 replies (of 1 total)
  • The topic ‘how to restrict subscriber user to a specific page post-product.php’ is closed to new replies.