Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Last active January 12, 2017 16:30
Show Gist options
  • Save bentasm1/864ce3221dce33ba9775 to your computer and use it in GitHub Desktop.
Save bentasm1/864ce3221dce33ba9775 to your computer and use it in GitHub Desktop.
WC Vendors Notify Vendor when Product is Approved
/* WC Vendors Pro - Notify Vendor when Product is Approved */
add_action( 'pending_to_publish', 'wcv_notify_vendor_on_publish' );
function wcv_notify_vendor_on_publish( $post_id ) {
global $post;
if ( $post->post_author != get_current_user_id() ) {
$author = new WP_User( $post->post_author );
$email_data = array(
'to' => $author->user_email,
'subject' => sprintf( __( 'Your post on %1$s has been published!', 'email_author_on_publish' ), get_bloginfo('name') ),
'message' => sprintf( __( 'Your post "%1$s" on %2$s has been published: %3$s', 'email_author_on_publish' ), $post->post_title, get_bloginfo( 'name' ), get_permalink( $post->ID ) ),
);
wp_mail( $email_data['to'], $email_data['subject'], $email_data['message'] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment