Action 'save_post' not working for quick edit
I have read other answers to similar questions but none of them solved my problem. This code works great in Editor but on Quick Edit or Bulk Edit it does not appear to fire at all. What am I doing wrong?
// link author display name to Broker Name if Author is Broker
add_action( 'save_post', 'author_is_broker', 200 );
function author_is_broker($post_id) {
// page/post options
global $lwp_options, $Listing;
$post_types = get_post_types();
unset($post_types['listings']);
$post_type = get_post_type();
//Only for listings
if(isset($post_type) $post_type == "listings"){
// Ignore for autosave
if ( defined( 'DOING_AUTOSAVE' ) DOING_AUTOSAVE ) {
return $post_id;
} else {
// If this is a revision, get real post ID
if ( $parent_id = wp_is_post_revision( $post_id ) )
$post_id = $parent_id;
// Get display name of post owner
$broker_id = get_post_field( 'post_author', $post_id );
$broker = get_the_author_meta('display_name', $broker_id);
// Verify directory exists for author
$args = array(
'post_type' = 'wpbdp_listing',
'author' = $broker_id
);
$wp_posts = get_posts($args);
if (count($wp_posts)) {
$is_broker = true;
} else {
return $post_id;
}
// If directory listing has been assigned, user is broker
if (isset($is_broker) $is_broker == true) {
// add the term
$term = sanitize_text_field($broker);
$Listing-add_listing_category_term('broker', $term);
// update the post
update_post_meta( (int) $post_id, 'broker', $term );
}
else {
return $post_id;
}
}
} else {
return $post_id;
}
}