AnsPress_Email_Hooks::ap_after_new_answer( integer $answer_id )
Description #
Send email after new answer.
Parameters #
- $answer_idinteger (Required) Answer ID.
Source #
File: addons/free/email.php
public static function ap_after_new_answer( $answer_id ) { $current_user = wp_get_current_user(); $args = array( 'users' => [], ); $admin_emails = self::get_admin_emails( 'email_admin_new_answer' ); if ( ! empty( $admin_emails ) ) { $args['users'] = $admin_emails; } $answer = ap_get_post( $answer_id ); if ( ap_opt( 'email_user_new_answer' ) && 'private_post' !== $answer->post_status && 'moderate' !== $answer->post_status ) { $subscribers = ap_get_subscribers( [ 'subs_event' => 'question', 'subs_ref_id' => $answer->post_parent ] ); foreach ( (array) $subscribers as $s ) { if ( ap_user_can_view_post( $answer ) && $s->user_email !== $current_user->user_email ) { $args['users'][] = $s->user_email; } } } $args['tags'] = array( '{answerer}' => ap_user_display_name( $answer->post_author ), '{question_title}' => get_the_title( $answer->post_parent ), '{answer_link}' => wp_get_shortlink( $answer->ID ), '{answer_content}' => $answer->post_content, '{answer_excerpt}' => ap_truncate_chars( strip_tags( $answer->post_content ), 100 ), ); $email = new Email( 'new_answer', $args ); $email->send_emails(); }
Expand full source code Collapse full source code View on GitHub: addons/free/email.php:327
Add your comment