LLMS_Abstract_User_Engagement::delete()

Delete the engagement


Return Return

(void)


Top ↑

Source Source

File: includes/abstracts/llms-abstract-user-engagement.php

	public function delete() {

		/**
		 * Action fired immediately prior to the deletion of a user's awarded engagement.
		 *
		 * The dynamic portion of the hook name, `$this->model_post_type`,
		 * refers to the engagement type, either "achievement" or "certificate".
		 *
		 * @since 3.18.0
		 * @since 6.0.0 Migrated from LLMS_User_Certificate and LLMS_User_Achievement.
		 *
		 * @param LLMS_Abstract_User_Engagement $User_Engagement Achievement or certificate class object.
		 */
		do_action( "llms_before_delete_{$this->model_post_type}", $this );

		global $wpdb;
		$id = $this->get( 'id' );
		$wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
			"{$wpdb->prefix}lifterlms_user_postmeta",
			array(
				'user_id'    => $this->get_user_id(),
				'meta_key'   => $this->get_user_post_meta_key(), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
				'meta_value' => $id, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
			),
			array( '%d', '%s', '%d' )
		);
		wp_delete_post( $id, true );

		/**
		 * Action fired immediately after the deletion of a user's awarded engagement.
		 *
		 * The dynamic portion of the hook name, `$this->model_post_type`,
		 * refers to the engagement type, either "achievement" or "certificate".
		 *
		 * @since 3.18.0
		 * @since 6.0.0 Migrated from LLMS_User_Certificate and LLMS_User_Achievement.
		 *
		 * @param LLMS_Abstract_User_Engagement $User_Engagement Achievement or certificate class object.
		 */
		do_action( "llms_delete_{$this->model_post_type}", $this );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Migrated from LLMS_User_Certificate and LLMS_User_Achievement.
3.18.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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