This is a tutorial for FreelanceEngine. It helps you prevent non-logged in users viewing the project details.

We can use WordPress’s hook: template_redirect to do this.  Simply add the below code to your child theme functions.php.

add_action('template_redirect', 'prevent_nologin_user_access_project');
function prevent_nologin_user_access_project() {
 if(is_singular( 'project' ) && !is_user_logged_in() ) {
 wp_redirect( home_url() );

The above code will redirect the users to the Home page. If you want redirect users to a specific page, you can change the link as below:

 wp_redirect( "your url" );

Also, you can easily prevent users entering other post type details page by changing “project ” to “your post type name”.

if(is_singular( 'the post type name' ) && !is_user_logged_in() ) {
 wp_redirect( home_url() );
  • sidhaarthaa
    Feb  10TH,  2015

    Will this work in Job Engine ? I don’t want users to see the resumes unless they sign in.

    • An
      Feb  10TH,  2015


      It also works for JobEngine. If you have any problem while edit it, you can send us a ticket via our forum. Our technical support staff here will help you solve the problem.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.