I am using a transition_post_status
hook for changing post status from private to publish
. The problem here is when admin changes the post status from private to publish, the post author gets changes.
I have made a custom post type abc
and added content via front end. I have set the status to private by default. so as admin can change from private to publish. for that i am using hook in functions.php.
here is the code that i have used
function _transition_post_status_1($new_status, $old_status, $post) {
global $wpdb;
if ( $old_status == 'private' && $new_status == 'publish' ) {
// Reset GUID if transitioning to publish and it is empty
$post_idd = $post->ID;
$post_7 = get_post($post_idd);
$post_athr = $post_7->post_author;
$auth_maill = get_the_author_meta( 'user_email', $post_athr );
if ( '' == get_the_guid($post->ID) ) {
$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
wp_mail($auth_maill,"Confirmation Email","Your Artist Campaign has been approved.");
do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish
}
}
add_action( 'transition_post_status','_transition_post_status_1',5, 3);