• Resolved Christien Paul

    (@christienpaul)


    The goal here is to redirect all user roles except job seekers to a custom page. So should a user with the role of “employer” try to open a job listing, they get redirected to a page that says “you need a job seeker account to view this listing”.

    Example page that needs the redirect: https://ccs4u.staging.wpengine.com/job/oxford-learning-centre-bolton-bolton-elementary-tutor/

    Destination page of redirect:
    https://ccs4u.staging.wpengine.com/employer-denied/

    The code I’ve been playing with in the child theme functions.php file is:

    // redirect user-role based on page template
    add_action(‘template_redirect’, ‘redirect_user_role’);

    function redirect_user_role()
    {
    if(current_user_can(’employer’) && is_page_template(‘single_job_listing’))
    {
    wp_redirect(‘https://ccs4u.staging.wpengine.com/employer-denied/’);
    }
    }

    I have added theme support:
    add_theme_support( ‘job-manager-templates’ );

    But this script does not work… I can get it to work referencing a page ID, page slug, etc. but I can’t seem to target the Job manager custom post type or page template using the following code:

    is_post_type_archive(‘job_listing’) – DOES NOT WORK

    Please advise, what is the best way to target the Job Listings? Template? Post Type?

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Redirect User Role based on Job Manager Template’ is closed to new replies.