function json_bp_rebuild_profile_map() { if (!class_exists('Agm_Bp_Pm_UserPages')) { die(-1); } global $wpdb; header('Content-type: application/json'); $sql = "SELECT DISTINCT ID FROM {$wpdb->users} WHERE ID NOT IN (SELECT DISTINCT ID FROM {$wpdb->users} as user, {$wpdb->usermeta} as meta WHERE user.ID=meta.user_id AND meta_key='agm-bp-profile_maps-location') LIMIT 1"; $user_id = (int) $wpdb->get_var($sql); $model = new AgmMapModel(); $opts = apply_filters('agm_google_maps-options-bp_profile_maps', get_option('agm_google_maps')); $address = bp_get_profile_field_data(array('field' => @$opts['bp_profile_maps-address_field'], 'user_id' => $user_id)); // Skip this guy if (!$address) { die(json_encode(array('user_id' => $user_id))); } $location = $model->_address_to_marker($address); if ($location) { $location['body'] = Agm_Bp_Pm_UserPages::get_location_body($user_id, $address); } update_user_meta($user_id, 'agm-bp-profile_maps-location', $location); die(json_encode(array('user_id' => $user_id))); }