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_Certificate_User::has_user_earned()

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


Description Description


Return Return

(boolean)


Top ↑

Source Source

File: includes/certificates/class.llms.certificate.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_certificate_template'
			  AND pm.meta_value = %d
			  AND upm.meta_key = '_certificate_earned'
			  AND upm.user_id = %d
			  AND upm.post_id = %d
			  LIMIT 1
			;",
			array( $this->certificate_template_id, $this->userid, $this->lesson_id )
		) );

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

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.4.1 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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