Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**********************************************************
- * This function extends Geo My WP to work with posts *
- * submitted via the Postie plugin. Those posts bypass *
- * the addition of the needed DB entries for geolocation *
- * searches. This adds them back in. *
- * *
- * REQUIREMENTS: *
- * - Geo My WP 2.0 Beta 5+ *
- * - Postie 1.5.14+ *
- **********************************************************/
- // Make sure we have the needed plugin.
- // if(!function_exists('gmw_pt_update_location'))
- function add_post_location($post) {
- DebugEcho("Adding post location...");
- DebugEcho("Loading GMW functions...");
- include_once("plugins/geo-my-wp/functions.php");
- DebugEcho("GMW functions loaded!");
- // Initialize variables.
- $id = $post['ID'];
- DebugEcho("Updating Post ID " . $id);
- $author_id = $post['post_author'];
- DebugEcho("Post author ID: " . $author_id);
- // Assumes an xprofile field of Street Address
- $street_address = xprofile_get_field_data("Street Address", $author_id);
- DebugEcho("Street Address: " . $street_address);
- // Assumes an xprofile field of City
- $city = xprofile_get_field_data("City", $author_id);
- DebugEcho("City: " . $city);
- // Assumes an xprofile field of State
- $state = xprofile_get_field_data("State", $author_id);
- DebugEcho("State: " . $state);
- // Assumes an xprofile field of Zip Code
- $zipcode = xprofile_get_field_data("ZIP Code", $author_id);
- DebugEcho("ZIP Code: " . $zipcode);
- $email = $post['email_author'];
- DebugEcho("Author email address: " . $email);
- // Set the phone number. In this case, we want only the set phone numbers.
- $home_phone = xprofile_get_field_data("Home Phone", $author_id);
- $cell_phone = xprofile_get_field_data("Cell Phone", $author_id);
- $phone = '';
- if($home_phone != '' && $cell_phone == '')
- $phone = $home_phone;
- if($home_phone == '' && $cell_phone != '')
- $phone = $cell_phone;
- if($home_phone != '' && $cell_phone != '')
- $phone = $home_phone + " / " + $cell_phone;
- DebugEcho("Phone: " . $phone);
- // Build an array for the update function.
- $options = array($id, 'post', 'published', $street_address, false, $city, $state, $zipcode, false, $phone, false, $email, false);
- DebugEcho("Running post update function...");
- // Run the update function.
- gmw_pt_update_location($options);
- DebugEcho("Done adding post location!");
- // As per Postie requirements, always return the $post object, even if it didn't change.
- return $post;
- }
- add_filter("postie_post_after", "add_post_location");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement