Generate Applicant List

false, 'parent' => $property_type ); $terms = get_terms( 'property_type', $args ); if ( !empty( $terms ) && !is_wp_error( $terms ) ) { foreach ($terms as $term) { $search_property_types[] = $term->term_id; $args = array( 'hide_empty' => false, 'parent' => $term->term_id ); $subterms = get_terms( 'property_type', $args ); if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) { foreach ($subterms as $term) { $search_property_types[] = $term->term_id; } } } } } } $search_property_types = array_unique($search_property_types); } $search_locations = array(); if ( isset($_POST['locations']) && is_array($_POST['locations']) && !empty($_POST['locations']) ) { foreach ( $_POST['locations'] as $location ) { $search_locations[] = (int)$location; $args = array( 'hide_empty' => false, 'parent' => $location ); $terms = get_terms( 'location', $args ); if ( !empty( $terms ) && !is_wp_error( $terms ) ) { foreach ($terms as $term) { $search_locations[] = $term->term_id; $args = array( 'hide_empty' => false, 'parent' => $term->term_id ); $subterms = get_terms( 'location', $args ); if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) { foreach ($subterms as $term) { $search_locations[] = $term->term_id; } } } } } } $search_locations = array_unique($search_locations); $args = array( 'post_type' => 'contact', 'fields' => 'ids', 'nopaging' => true, ); $args['meta_query'] = array(); $args['meta_query'][] = array( 'key' => '_contact_types', 'value' => 'applicant', 'compare' => 'LIKE' ); $applicant_query = new WP_Query($args); $results = array(); if ( $applicant_query->have_posts() ) { while ( $applicant_query->have_posts() ) { $applicant_query->the_post(); $num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE ); if ( $num_applicant_profiles == '' ) { $num_applicant_profiles = 0; } for ( $i = 0; $i < $num_applicant_profiles; ++$i ) { $profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE ); $match = true; if ( !isset($profile['send_matching_properties']) || ( isset($profile['send_matching_properties']) && $profile['send_matching_properties'] != 'yes' ) ) { $match = false; } if ( isset($_POST['department']) ) { if ( isset($profile['department']) && $profile['department'] != ph_clean($_POST['department']) ) { $match = false; } } if ( isset($_POST['department']) && $_POST['department'] == 'residential-sales' ) { if ( isset($_POST['maximum_price']) && ph_clean($_POST['maximum_price']) != '' ) { $price = preg_replace("/[^0-9]/", '', ph_clean($_POST['maximum_price'])); if ( isset($profile['max_price_actual']) && $profile['max_price_actual'] != '' && $profile['max_price_actual'] != 0 && $profile['max_price_actual'] < $price ) { $match = false; } } } if ( isset($_POST['department']) && $_POST['department'] == 'residential-lettings' ) { if ( isset($_POST['maximum_rent']) && ph_clean($_POST['maximum_rent']) != '' ) { $price = preg_replace("/[^0-9]/", '', ph_clean($_POST['maximum_rent'])); if ( isset($profile['max_rent_actual']) && $profile['max_rent_actual'] != '' && $profile['max_rent_actual'] != 0 && $profile['max_rent_actual'] < $price ) { $match = false; } } } if ( isset($_POST['department']) && ( $_POST['department'] == 'residential-sales' || $_POST['department'] == 'residential-lettings' ) ) { if ( isset($_POST['minimum_bedrooms']) && ph_clean($_POST['minimum_bedrooms']) != '' ) { $beds = preg_replace("/[^0-9]/", '', ph_clean($_POST['minimum_bedrooms'])); if ( isset($profile['min_beds']) && $profile['min_beds'] != '' && $profile['min_beds'] != 0 && $profile['min_beds'] > $beds ) { $match = false; } } // Property Types if ( isset($_POST['property_types']) && is_array($_POST['property_types']) && !empty($_POST['property_types']) ) { $found_type = false; foreach ( $search_property_types as $search_property_type ) { if ( isset($profile['property_types']) && is_array($profile['property_types']) && in_array($search_property_type, $profile['property_types']) ) { $found_type = true; } } if ( !$found_type ) { $match = false; } } } if ( isset($_POST['locations']) && is_array($_POST['locations']) && !empty($_POST['locations']) ) { $found_type = false; foreach ( $search_locations as $search_location ) { if ( isset($profile['locations']) && is_array($profile['locations']) && in_array($search_location, $profile['locations']) ) { $found_type = true; } } if ( !$found_type ) { $match = false; } } if ( $match ) { $contact_details = array(); if ( get_post_meta( get_the_ID(), '_telephone_number', TRUE ) != '' ) { $contact_details[] = 'T: ' . get_post_meta( get_the_ID(), '_telephone_number', TRUE ); } if ( get_post_meta( get_the_ID(), '_email_address', TRUE ) != '' ) { $contact_details[] = 'E: ' . get_post_meta( get_the_ID(), '_email_address', TRUE ); } $results[] = array( 'name' => get_the_title(), 'edit_link' => get_edit_post_link(get_the_ID()), 'contact_details' => implode("
", $contact_details), 'profile' => $profile ); } } } } wp_reset_postdata(); ?>

Applicants Found Matching Your Criteria

Applicant Name Contact Details Requirements
Max Price: £' . number_format($result['profile']['max_price']); } if ( isset($result['profile']['min_beds']) && $result['profile']['min_beds'] != '' && $result['profile']['min_beds'] != 0 ) { $output[] = 'Min Beds: ' . number_format($result['profile']['min_beds']); } if ( isset($result['profile']['property_types']) && is_array($result['profile']['property_types']) && !empty($result['profile']['property_types']) ) { $output_types = array(); foreach ( $result['profile']['property_types'] as $profile_type ) { $output_types[] = $property_types[$profile_type]; } $output[] = 'Property Types: ' . implode(", ", $output_types); } if ( isset($result['profile']['locations']) && is_array($result['profile']['locations']) && !empty($result['profile']['locations']) ) { $output_locations = array(); foreach ( $result['profile']['locations'] as $profile_location ) { $output_locations[] = $locations[$profile_location]; } $output[] = 'Locations: ' . implode(", ", $output_locations); } if ( isset($result['profile']['notes']) && $result['profile']['notes'] != '' ) { $output[] = 'Additional Requirements: ' . nl2br($result['profile']['notes']); } echo( !empty($output) ? implode("
", $output) : '-' ); break; } case "residential-lettings": { $output = array(); if ( isset($result['profile']['max_rent']) && $result['profile']['max_rent'] != '' && $result['profile']['max_rent'] != 0 ) { $output[] = 'Max Rent: £' . number_format($result['profile']['max_rent']) . $result['profile']['rent_frequency']; } if ( isset($result['profile']['min_beds']) && $result['profile']['min_beds'] != '' && $result['profile']['min_beds'] != 0 ) { $output[] = 'Min Beds: ' . number_format($result['profile']['min_beds']); } if ( isset($result['profile']['property_types']) && is_array($result['profile']['property_types']) && !empty($result['profile']['property_types']) ) { $output_types = array(); foreach ( $result['profile']['property_types'] as $profile_type ) { $output_types[] = $property_types[$profile_type]; } $output[] = 'Property Types: ' . implode(", ", $output_types); } if ( isset($result['profile']['locations']) && is_array($result['profile']['locations']) && !empty($result['profile']['locations']) ) { $output_locations = array(); foreach ( $result['profile']['locations'] as $profile_location ) { $output_locations[] = $locations[$profile_location]; } $output[] = 'Locations: ' . implode(", ", $output_locations); } if ( isset($result['profile']['notes']) && $result['profile']['notes'] != '' ) { $output[] = 'Additional Requirements: ' . nl2br($result['profile']['notes']); } echo( !empty($output) ? implode("
", $output) : '-' ); break; } case "commercial": { $output = array(); /*if ( isset($result['profile']['max_price']) && $result['profile']['max_price'] != '' && $result['profile']['max_price'] != 0 ) { $output[] = 'Max Price: £' . number_format($result['profile']['max_price']); } if ( isset($result['profile']['min_beds']) && $result['profile']['min_beds'] != '' && $result['profile']['min_beds'] != 0 ) { $output[] = 'Min Beds: ' . number_format($result['profile']['min_beds']); } if ( isset($result['profile']['property_types']) && is_array($result['profile']['property_types']) && !empty($result['profile']['property_types']) ) { $output_types = array(); foreach ( $result['profile']['property_types'] as $profile_type ) { $output_types[] = $property_types[$profile_type]; } $output[] = 'Property Types: ' . implode(", ", $output_types); }*/ if ( isset($result['profile']['locations']) && is_array($result['profile']['locations']) && !empty($result['profile']['locations']) ) { $output_locations = array(); foreach ( $result['profile']['locations'] as $profile_location ) { $output_locations[] = $locations[$profile_location]; } $output[] = 'Locations: ' . implode(", ", $output_locations); } if ( isset($result['profile']['notes']) && $result['profile']['notes'] != '' ) { $output[] = 'Additional Requirements: ' . nl2br($result['profile']['notes']); } echo( !empty($output) ? implode("
", $output) : '-' ); break; } } } ?>