Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode('publish_party', 'party_contact_suppliers');
- function party_contact_suppliers(){
- $alerts = new WP_Query (array (
- 'post_type' => 'alert',
- 'post_status' => 'publish'));
- $address_cache = get_option( 'toolset_maps_address_coordinates' );
- // Ballito
- $home_lat = -29.4872902;
- $home_lon = 31.1613188;
- echo '<h3>Ballito</h3>';
- echo '<ol>';
- while($alerts->have_posts()) {
- $alerts->the_post();
- $id = get_the_ID();
- $author = get_the_author();
- $author_id = get_the_author_id();
- $emailaddress = the_author_meta('user_email',$author_id);
- $center_location = get_post_meta($id,'wpcf-center-location',true);
- $radius = get_post_meta($id,'wpcf-radius',true);
- $lat = 0;
- $lon = 0;
- foreach ($address_cache as $key => $value) {
- if ( $value['address_passed'] == $center_location ) {
- $lat = $value['lat'];
- $lon = $value['lon'];
- break;
- }
- }
- $distance = distance($lat,$lon,$home_lat,$home_lon);
- echo '<li>';
- echo '<p>Alert Post ID: '.$id.' Author Name:'.$author.' Author ID: '.$author_id.' Email Address: '.$emailaddress.'</p>';
- echo '<p>Author location: '.$center_location.' Lat: '.$lat.' Long: '.$lon.' Distance: '.$distance.'Kms</p>';
- if ($distance <= $radius) {
- echo '<p style="color:green">Distance is within radius of '.$radius.' Kms. Send email to '.$emailaddress.'</p>';
- }
- else { echo '<p style="color:red">Distance is not within radius of '.$radius.' Kms.</p>';}
- echo '</li>';
- }
- echo '</ol>';
- wp_reset_postdata();
- }
Add Comment
Please, Sign In to add comment