AnsPress_Email_Hooks::new_comment( object $comment )
Description #
Notify admin on new comment and is not approved.
Parameters #
- $commentobject (Required) Comment object.
Source #
File: addons/free/email.php
public static function new_comment( $comment ) { $args = []; $admin_emails = self::get_admin_emails( 'email_admin_new_comment' ); if ( ! empty( $admin_emails ) ) { $args['users'] = $admin_emails; } if ( ap_opt( 'email_user_new_comment' ) ) { $current_user = wp_get_current_user(); $post = ap_get_post( $comment->comment_post_ID ); $subscribers = ap_get_subscribers( [ 'subs_event' => 'comment_' . $comment->comment_post_ID ] ); if ( $post->post_author != get_current_user_id() ) { $args['users'][] = $post->post_author; } foreach ( (array) $subscribers as $s ) { if ( ap_user_can_view_post( $post ) && $s->user_email !== $current_user->user_email ) { $args['users'][] = $s->user_email; } } } // Check if have emails before proceeding. if ( empty( $args['users'] ) ) { return; } $args['tags'] = array( '{commenter}' => ap_user_display_name( $comment->user_id ), '{question_title}' => $post->post_title, '{comment_link}' => get_comment_link( $comment ), '{comment_content}' => $comment->comment_content, ); $email = new Email( 'new_comment', $args ); $email->send_emails(); }
Expand full source code Collapse full source code View on GitHub: addons/free/email.php:397
Add your comment