ap_is_user_answered( integer $question_id, integer $user_id )

Description #

Check if user answered on a question.

Parameters #

  • $question_id
    integer (Required) Question ID.
  • $user_id
    integer (Required) User ID.

Changelog #


Source #

File: includes/functions.php

function ap_is_user_answered( $question_id, $user_id ) {
	global $wpdb;

	$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts where post_parent = %d AND ( post_author = %d AND post_type = 'answer')", $question_id, $user_id ) ); // phpcs:ignore WordPress.DB

	return $count > 0 ? true : false;

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