Get post_author email for Zapier Integration

There’s no direct way of getting the post author’s email from a post. You can get the email by using the author ID, which is present in standard WP_Post object. $post_author_id = intval( $post->post_author ); $post_author_email = get_the_author_meta(’email’, $post_author_id); Or if you just have the post ID $post_author_id = intval( get_post_field( ‘post_author’, $post_id ) ); … Read more

Updating a related post’s “post_modified” value

Had a brainwave whilst typing up the question.. there are other actions that fire when a post is updated, such as post_updated which naturally update the post_modified timestamp. Instead I decided to save the activity’s modified time as a meta value, and will sort on that instead and leave the post_modified functionality intact. The trimmed … Read more

Get original value in save_post action hooka

This is the solution: add_action(‘pre_post_update’, function($post_id, $post_data) { global $original_post; $original_post = get_post($post_id); }, 10, 2); add_action( ‘save_post_’, function($post_id, $post, $update) { global $original_post; $original_post->post_title; // original post title $post->post_title; // new post title }, 10, 3);

using filter and hook inside class

No, constructors should not define hooks. Constructors should be used to set the initial state of the object. Hooks have nothing to do with the object’s initial state, so they don’t belong in the constructor. Constructors should not have “side effects”, so that using new ClassName() does not affect any other parts of the program, … Read more