I have a website based on WordPress, built with pages. I need to have:
- public content
- pages that are only accessible to logged in users
- pages that are only accessible to a certain subset of logged in users
I have accomplished this with Role Scoper. However, there is an important capability that this doesn’t provide. I would like to be able to publish (say via email) a link to one of the “restricted” pages, and then when someone went to it, have the login screen presented and after successful login have the appropriate page displayed. With role scoper, if you direct a user to a restricted page they just get the “page not found” error.
Anyone found a good solution for this?
Use could use a couple of built in wordpress functions. The ones I’d choose are:
<?--php is_user_logged_in() ?><?--php current_user_can(...) ?>is_user_logged_in()is a simple check that does exactly as it says, checks if the user is logged in. If they are, it returns true. If not, it returns false.Current_user_can()performs the same way; if you look at the capabilities on http://codex.wordpress.org/Roles_and_Capabilities you can simply use those to simulate user levels (there’s another function that does this in a more direct way but I can’t remember it off the top of my head.Really, what I’m trying to get at, is that you can set up specific pages that have your content and perform a role check before the header loads. If you want to have them login before hand, you could generate a login url w/ redirect using
<?--php echo wp_login_url( $redirect ); ?>, which would take them to$redirectafter they login.