Change WordPress user roles and capabilities › Forums › How to or FAQ › Block front-end options
Tagged: User Access
- This topic has 4 replies, 2 voices, and was last updated 9 years, 10 months ago by Vladimir.
-
AuthorPosts
-
21/01/2015 at 14:59 #1363raheb9Participant
Hello, I am working on a Job Portal wherein, after a candidate logs in, I can disable the ‘post a Job’ page. And if the employer logs in, I can disable the ‘Post a Resume’ page.
I have also purchased the Pro plugin just moments ago but am a bit confused.
My site: jobs.anoc.ae
21/01/2015 at 16:20 #1364raheb9ParticipantHi, I tried activating & using Content View Restrictions. Set the Action: Prohibit Access for Role: candidate.
It successfully blocks the page (post a job) for the candidate role. However, even when I log out and act as Public/Viewer, I cannot access the page ‘Post a Job). I also do not see a role as Public in the Roles List. Please advise.21/01/2015 at 16:43 #1365VladimirKeymasterHi,
If you set any view restriction for the post, that becomes unavailable for public visitors or not logged in users. In other case a user with role ‘candidate’ may log out and easy post a job as not logged in user.
I suppose that not logged in users should not have right to send as job, as resume at your site.21/01/2015 at 16:53 #1366raheb9ParticipantYes you are right, but my theme functionality is, if you click on Post a job or Add Resume button on home page, it will take you to login page. Any option where we can create a Public/Viewer user role?
22/01/2015 at 02:19 #1367VladimirKeymasterIn order to have a role, a user should login 1st. Not logged in user can not have any role.
As home page is available to the public I offer you replace those links for not logged in users with the registration/login links.
And add a filter for automatic redirection after login to the restricted page according to the assigned role. Like this:add_filter('login_redirect', 'redirect_user_after_login', 10, 3); function redirect_user_after_login($redirect_to, $request, $user) { if (isset( $user->allcaps ) && is_array( $user->allcaps )) { //check for admins if (!empty($user->allcaps['administrator'])) { // redirect them to the default place return $redirect_to; } else if (!empty($user->allcaps['candidate'])) { $redirect_to = home_url() .'/post-resume'; } else if (!empty($user->allcaps['employer'])) { $redirect_to = home_url() .'/post-job'; } else { return home_url(); } } else { return $redirect_to; } }
-
AuthorPosts
- You must be logged in to reply to this topic.