AnsPress_Email_Hooks::select_answer( object $_post )

Description #

Notify answer author that his answer is selected as best.

Parameters #

  • $_post
    object (Required) Selected answer object.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: addons/free/email.php

	public static function select_answer( $_post ) {
		if ( get_current_user_id() === $_post->post_author || ! ap_opt( 'email_user_select_answer' ) ) {
			return;
		}

		$args = array(
			'users' => [
				get_the_author_meta( 'email', $_post->post_author )
			],
		);

		$args['tags'] = array(
			'{selector}'        => ap_user_display_name( get_current_user_id() ),
			'{question_title}'  => $_post->post_title,
			'{answer_link}'     => wp_get_shortlink( $_post->ID ),
			'{answer_content}'  => $_post->post_content,
			'{answer_excerpt}'  => ap_truncate_chars( strip_tags( $_post->post_content ), 100 ),
		);

		$email = new Email( 'select_answer', $args );
		$email->send_emails();
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment