LLMS_Achievement::create( string $content )
Create the achievement
Description Description
Parameters Parameters
- $content
-
(string) (Required) achievement body content
Return Return
(void)
Source Source
File: includes/class.llms.achievement.php
public function create( $content ) { global $wpdb; $new_user_achievement = apply_filters( 'lifterlms_new_achievement', array( 'post_type' => 'llms_my_achievement', 'post_title' => $this->title, 'post_content' => $content, 'post_status' => 'publish', 'post_author' => 1, ) ); $new_user_achievement_id = wp_insert_post( $new_user_achievement, true ); update_post_meta( $new_user_achievement_id,'_llms_achievement_title', $this->achievement_title ); update_post_meta( $new_user_achievement_id,'_llms_achievement_image', $this->image ); update_post_meta( $new_user_achievement_id,'_llms_achievement_content', $this->content ); update_post_meta( $new_user_achievement_id,'_llms_achievement_template', $this->achievement_template_id ); $user_metadatas = array( '_achievement_earned' => $new_user_achievement_id, ); foreach ( $user_metadatas as $key => $value ) { $update_user_postmeta = $wpdb->insert( $wpdb->prefix . 'lifterlms_user_postmeta', array( 'user_id' => $this->userid, 'post_id' => $this->lesson_id, 'meta_key' => $key, 'meta_value' => $value, 'updated_date' => current_time( 'mysql' ), ) ); } /** * Allow 3rd parties to hook into the generation of an achievement * Notifications uses this * note 3rd param $this->lesson_id is actually the related post id (but misnamed) */ do_action( 'llms_user_earned_achievement', $this->userid, $new_user_achievement_id, $this->lesson_id ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: