if ( $user_id && !$task_id ) {
$get_results = $wpdb->get_results( "SELECT * FROM $table_name sender_id = $user_id", ARRAY_A );
} elseif ( !$user_id && $task_id) {
$get_results = $wpdb->get_results( "SELECT * FROM $table_name WHERE task_id = $task_id", ARRAY_A );
} else {
$get_results = $wpdb->get_results( "SELECT * FROM $table_name WHERE task_id = $task_id AND sender_id = $user_id", ARRAY_A );
}
return $get_results;