Warning: This method has been deprecated. LLMS_Achievement_User::has_user_earned() is deprecated with no replacement instead.

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Achievement_User::has_user_earned()

Check if the user has already earned this achievement used to prevent duplicates


Return Return

(boolean)


Top ↑

Source Source

File: includes/achievements/class.llms.achievement.user.php

	private function has_user_earned() {

		global $wpdb;

		$count = (int) $wpdb->get_var(
			$wpdb->prepare(
				"
			SELECT COUNT( pm.meta_id )
			FROM {$wpdb->postmeta} AS pm
			JOIN {$wpdb->prefix}lifterlms_user_postmeta AS upm ON pm.post_id = upm.meta_value
			WHERE pm.meta_key = '_llms_achievement_template'
			  AND pm.meta_value = %d
			  AND upm.meta_key = '_achievement_earned'
			  AND upm.user_id = %d
			  AND upm.post_id = %d
			  LIMIT 1
			;",
				array( $this->achievement_template_id, $this->userid, $this->lesson_id )
			)
		);

		/**
		 * @filter llms_achievement_has_user_earned
		 * Allow 3rd parties to override default dupcheck functionality for achievements
		 */
		return apply_filters( 'llms_achievement_has_user_earned', ( $count >= 1 ), $this );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 LLMS_Achievement_User::has_user_earned() is deprecated with no replacement.
3.4.1 This method has been deprecated. LLMS_Achievement_User::has_user_earned() is deprecated with no replacement instead.
3.17.4 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.