Get Category in save_post Hook
in a class I have a function for save_post action. In this function I send an email. All this works except for querying the categories for that post:
class _new_notifications
{
public function __construct()
{
add_action( 'save_post', array( $this, 'send_new_post_notifications' ) );
}
public function send_new_post_notifications( $post_id ){
$send_notify = get_field('send_notifications', 'option');
if ( !$send_notify || wp_is_post_revision( $post_id ) ) {
return;
}
$categorie = get_the_category( $post_id );
$cat = $categorie[0]-name;
//doing other stuff...
I already tried everything possible (several hours :) but I just do not get the category for that post ID.
Maybe someone can. help? Many Thanks!!