AnsPress_Email_Hooks::ap_after_new_question( integer $question_id )

Description #

Send email to admin when new question is created.

Parameters #

  • $question_id
    integer (Required) Question ID.

Changelog #

VersionDescription
4.1.0Updated to use new Email class.
1.0Introduced.

Source #

File: addons/free/email.php

	public static function ap_after_new_question( $question_id ) {
		$args = [];

		$admin_emails = self::get_admin_emails( 'email_admin_new_question' );

		if ( ! empty( $admin_emails ) ) {
			$args['users'] = $admin_emails;
		}

		// Return if no users.
		if ( empty( $args['users'] ) ) {
			return;
		}

		$question = ap_get_post( $question_id );
		$args['tags'] = array(
			'{asker}'             => ap_user_display_name( $question->post_author ),
			'{question_title}'    => $question->post_title,
			'{question_link}'     => wp_get_shortlink( $question->ID ),
			'{question_content}'  => apply_filters( 'the_content', $question->post_content ),
			'{question_excerpt}'  => ap_truncate_chars( strip_tags( $question->post_content ), 100 ),
		);

		$email = new Email( 'new_question', $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