LD_ACHIEVEMENTS_AWARD::award_achievement( $user_id, $action_data, $recipe_id, $args )
Awards the achievement.
Source Source
File: src/integrations/learndash/actions/ld-achievements-award.php
public function award_achievement( $user_id, $action_data, $recipe_id, $args ) { $award_id = Automator()->parse->text( $action_data['meta'][ $this->action_meta ], $recipe_id, $user_id, $args ); $award = get_post( $award_id ); if ( class_exists( '\LearnDash\Achievements\Achievement' ) ) { if ( method_exists( '\LearnDash\Achievements\Achievement', 'store' ) ) { $stored = \LearnDash\Achievements\Achievement::store( $award, $user_id ); if ( false === $stored ) { $error_message = esc_attr__( 'There was an error encountered while giving award to the user.', 'uncanny-automator' ); $action_data['complete_with_errors'] = true; Automator()->complete->action( $user_id, $action_data, $recipe_id, $error_message ); } Automator()->complete->action( $user_id, $action_data, $recipe_id ); return; } $error_message = esc_attr__( 'Error: The method `store` in `Achievement` Class is not found.', 'uncanny-automator' ); $action_data['complete_with_errors'] = true; Automator()->complete->action( $user_id, $action_data, $recipe_id, $error_message ); } else { $error_message = esc_attr__( "Error: Instance of '\LearnDash\Achievements\Achievement' is not found.", 'uncanny-automator' ); $action_data['complete_with_errors'] = true; Automator()->complete->action( $user_id, $action_data, $recipe_id, $error_message ); } }
Expand full source code Collapse full source code View on Github