post_author; if ( current_user_can( 'edit_others_posts', $post_id ) || ($post_author_id == $current_user->ID) ) { update_post_meta($post_id, $key, $value); wp_send_json_success(); } else { wp_send_json_error(); } } else { wp_send_json_error(); }