Can't get a custom admin notice working, here's my code... not sure what's wrong.
function set_ll() {
global $post;
add_action('admin_notices', 'my_admin_notice');
if ($post->post_type == 'listings') {
global $post;
$p['address'] = get_post_meta($post->ID, 'street_address', true);
$p['city'] = get_post_meta($post->ID, 'city', true);
$p['province'] = get_post_meta($post->ID, 'province', true);
$p['postal_code'] = get_post_meta($post->ID, 'postal_code', true);
$p['query'] = $p['address'] . ' ' . $p['city'] . ', ' . $p['province'];
$p['result'] = getLatLng($p['query']);
if ($p['result']) {
//echo 'true';
add_action('admin_notices', 'my_admin_notice');
} else {
add_action('admin_notices', 'my_admin_notice');
}
$p['long'] = $p['result']['lng'];
$p['lat'] = $p['result']['lat'];
//delete_post_meta($post->ID,'lat');
//delete_post_meta($post->ID,'long');
//update_post_meta($post->ID, 'lat', $p['long']);
//update_post_meta($post->ID, 'long', $p['lat']);
}
}
function my_admin_notice() {
echo '<div class="error">
<p>Aenean eros ante, porta commodo lacinia.</p>
</div>';
}
add_action('save_post', 'set_ll');
?>