Restrict jobs page to logged in users
-
I tried this snippet to restrict jobs listings only to logged in users but it does not work. Could you please help find what’s wrong there ?
<?php // Check if user is logged in if ( !is_user_logged_in() ){ echo "Vous devez d'abord créer un compte en soumettant un CV ou vous connecter depuis votre tableau de bord pour accéder aux annonces"; wp_login_form( array( 'echo' => true ) ); }else{ // Show content <?php global $post; ?> <li <?php job_listing_class(); ?> data-longitude="<?php echo esc_attr( $post->geolocation_lat ); ?>" data-latitude="<?php echo esc_attr( $post->geolocation_long ); ?>"> <?php if( function_exists('user_has_applied_for_job') ) { ?> <a href="<?php the_job_permalink(); ?>"<?php if( user_has_applied_for_job(get_current_user_id(), $post->ID) ) { echo ' class="applied"'; } ?>> <?php } else { ?> <a href="<?php the_job_permalink(); ?>"> <?php } ?> <div class="row"> <div class="col job-logo"> <?php the_company_logo(); ?> </div> <div class="col job-title"> <?php the_title('<h5>', '</h5>'); ?> <?php the_company_name( '<strong>', '</strong>' ); ?> <?php the_company_tagline(); ?> </div> <div class="col job-location"> <?php the_job_location( false ); ?> </div> <div class="col job-type"> <ul> <?php do_action( 'job_listing_meta_start' ); ?> <li class="badge job-type <?php echo get_the_job_type() ? sanitize_title( get_the_job_type()->slug ) : ''; ?>"><?php the_job_type(); ?></li> </ul> </div> <div class="col job-dates"> <ul> <li class="job-posted"><strong><?php printf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); ?></strong></li> <?php do_action( 'job_listing_meta_end' ); ?></li> </ul> </div> </div> </a> </li> } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Restrict jobs page to logged in users’ is closed to new replies.