Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('after_wcfm_articles_manage_meta_save', function($article_id) {
- global $WCFM;
- $article = get_post($article_id);
- $vendor_id = $article->post_author;
- $vendor_id = apply_filters('wcfm_current_vendor_id', $vendor_id);
- if(!$vendor_id) return;
- $article_status = get_post_status( $article_id );
- if( $article_status == 'pending' ) {
- $wcfm_review_article_notified = get_post_meta( $article_id, '_wcfm_review_article_notified', true );
- if( !$wcfm_review_article_notified ) {
- $author_id = $vendor_id;
- $author_is_admin = 0;
- $author_is_vendor = 1;
- $message_to = 0;
- $wcfm_messages = sprintf( __( 'An Article <b>%s</b> is awaiting for review', 'wc-frontend-manager' ), '<a class="wcfm_dashboard_item_title" href="' . get_wcfm_articles_manage_url( $article_id ) . '">' . get_the_title( $article_id ) . '</a>' );
- $WCFM->wcfm_notification->wcfm_send_direct_message( $author_id, $message_to, $author_is_admin, $author_is_vendor, $wcfm_messages, 'article_review', apply_filters( 'wcfm_is_allow_review_article_notification_email', true ) );
- update_post_meta( $article_id, '_wcfm_review_article_notified', 'yes' );
- do_action( 'wcfm_after_review_article_by_vendor', $article_id, $vendor_id );
- }
- } else {
- if( $article_status != 'publish' ) return;
- $wcfm_new_article_notified = get_post_meta( $article_id, '_wcfm_new_article_notified', true );
- if( !$wcfm_new_article_notified ) {
- $author_id = $vendor_id;
- $author_is_admin = 0;
- $author_is_vendor = 1;
- $message_to = 0;
- $wcfm_messages = sprintf( __( 'A new article <b>%s</b> is added by <b>%s</b>', 'wc-frontend-manager' ), '<a class="wcfm_dashboard_item_title" href="' . get_permalink( $article_id ) . '">' . get_the_title( $article_id ) . '</a>', wcfm_get_vendor_store( $vendor_id ) );
- $WCFM->wcfm_notification->wcfm_send_direct_message( $author_id, $message_to, $author_is_admin, $author_is_vendor, $wcfm_messages, 'new_article', apply_filters( 'wcfm_is_allow_new_article_notification_email', false ) );
- update_post_meta( $article_id, '_wcfm_new_article_notified', 'yes' );
- do_action( 'wcfm_after_new_article_by_vendor', $article_id, $vendor_id );
- }
- }
- });
- add_filter('wcfm_message_types', function($message_types) {
- $article_types = array(
- 'article_review' => 'Article Review',
- 'new_article' => 'New Article',
- );
- return $message_types + $article_types;
- }, 200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement