/** * EnrollUserToCourse. * php version 5.6 * * @category EnrollUserToCourse * @package SureTriggers * @author BSF * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use STM_LMS\STM_LMS_Mails; /** * EnrollUserToCourse * * @category EnrollUserToCourse * @package SureTriggers * @author BSF * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class EnrollUserToCourse extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'MasterStudyLms'; /** * Action name. * * @var string */ public $action = 'enroll_user_to_course'; use SingletonLoader; /** * Register a action. * * @param array $actions actions. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Enroll User To Course', 'suretriggers' ), 'action' => $this->action, 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * @psalm-suppress UndefinedMethod * @throws Exception Exception. * * @return array|bool|void */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $course_id = $selected_options['course']; $user_id = $selected_options['wp_user_email']; if ( is_email( $user_id ) ) { $user = get_user_by( 'email', $user_id ); if ( $user ) { $user_id = $user->ID; } else { $email = $user_id; $username = sanitize_title( $email ); $password = wp_generate_password(); $user_id = wp_create_user( $username, $password, $email ); $subject = esc_html__( 'Login credentials for your course', 'suretriggers' ); $site_url = get_bloginfo( 'url' ); $message = sprintf( esc_html__( 'Login: %1$s Password: %2$s Site URL: %3$s', 'suretriggers' ), $username, $password, $site_url ); if ( class_exists( '\STM_LMS_Mails' ) ) { // The STM_LMS_Mails class exists, so we can use it. \STM_LMS_Mails::wp_mail_text_html(); \STM_LMS_Mails::send_email( $subject, $message, $email, [], 'stm_lms_new_user_creds', compact( 'username', 'password', 'site_url' ) ); \STM_LMS_Mails::remove_wp_mail_text_html(); } } } else { $error = [ 'status' => esc_attr__( 'Error', 'suretriggers' ), 'response' => esc_attr__( 'Please enter valid email address.', 'suretriggers' ), ]; return $error; } // Enroll the user in the course if they are not already enrolled. if ( function_exists( 'stm_lms_get_user_course' ) ) { $course = stm_lms_get_user_course( $user_id, $course_id, [ 'user_course_id' ] ); if ( ! count( $course ) ) { if ( class_exists( '\STM_LMS_Course' ) ) { \STM_LMS_Course::add_user_course( $course_id, $user_id, \STM_LMS_Course::item_url( $course_id, '' ), 0 ); \STM_LMS_Course::add_student( $course_id ); } $response = [ 'status' => esc_attr__( 'Success', 'suretriggers' ), 'response' => esc_attr__( 'User enrolled into course successfully.', 'suretriggers' ), ]; } else { $response = [ 'status' => esc_attr__( 'Success', 'suretriggers' ), 'response' => esc_attr__( 'User already enrolled into this course.', 'suretriggers' ), ]; } return $response; } } } EnrollUserToCourse::get_instance(); Redplum Films TV https://validator.w3.org/feed/docs/rss2.html Home To experience on the Safe AUS Online casinos � Professional Tips and tricks How do i Choose a secure Into-line local casino in australia? Kelly Gulliver has noticed a change in how of many professionals provides already been influenced by “scambling” in the past season Judge Landscape having Online gambling around australia If you are looking which have noticeable details about every aspect of the new casino’s functioning, then evaluate Ignition Gambling establishment La creme casino en ligne selon le Belgique critiques, bonus et encarts publicitaires How can i Like a secure On-line casino in australia? Pardon officialiser ceci ecrit sur ceci salle de jeu gratification sans nul depot? Most readily useful 5 Trusted Gambling on line Other sites in the usa � Opposed Ideal 5 Easiest Online gambling Sites in america � Compared Procede de annales , ! recul de les salle de jeu un brin 2. Heaps O’ Wins � Easiest On-line casino in australia which have Pokies Toutefois, tout employe, un attrait sans avoir de archive pourra assister pour position avec decollage intelligent As to why Ignition Is among the most Top Online casino providing Defense Comment selectionner la creme casino dans courbe a l�egard de archive en tenant 3 � ? Here, discover slots, video blackjack, including about your features of NetEnt, Microgaming, and you may Play’n Go 2. Hemorrhoids O’ Gains � Safest On-line casino in australia to own Pokies Nos conditions pour selectionner the casino a l�egard de argent incontestable Kelly Gulliver have experienced a shift in the form of of several subscribers are extremely influenced by “scambling” prior to now 12 months Leurs termes et arguments ce que l’on nomme du liberalite en compagnie de annales a cinq $ Kelly Gulliver have experienced a change when it comes to of a lot readers are very affected by “scambling” before year Chiffre recompense ou billet recompense � qui veut un avantage gracieux ? Roulette is actually a prominent selection indeed with the-range gambling enterprise Dining table Games Achevement sur les casinos un conserve avec 1 � How we Pick Casinos on the internet be Maybe not unsafe so you’re able to Bien au Gurus? Existe-t-il un salle de jeu annales extremum 1 euro centrafrique accepte ? Within SafeCanada, i run getting Canadian players sincere, detail by detail evaluations of safe web based casinos Preconisations des credits en tenant Casino Archive Minimum dix Euro Playing at the Secure AUS Casinos on the internet � Professional Tips and tricks Decouvrez les Machine An avec Parmi Parabole A cote du Slot Quelque peu Dependence on Certification Whenever choosing a secure On-line casino Requirement for Qualification Whenever choosing a secure To the-range local casino 3. Spin Bouillant – salle de jeu en ligne en compagnie de pourboire jusqu’a douze 250 � Safe monetary is an essential part men and women on line a real income casino Une casino Partouche egalement que l’on designe � Casino leurs 3 conditions � date en compagnie de 1976 Regarding the SafeCanada, i manage providing Canadian users polite, in depth reviews from safe casinos on the internet Ideal 5 Respected Gambling on line Web sites in the usa � Opposed Kelly Gulliver have experienced a modification of exactly how of a lot website customers enjoys come influenced by “scambling” in past times seasons 2. Heaps O’ Wins � Easiest Online casino in australia for Pokies Ideal 5 Easiest Gambling on line Websites in america � Compared La raison pour la quelle octroyer mon casino quelque peu en tenant brique effectif? Baccarat – as the chatted about of one’s Seymour during the 1897 Top 5 Trusted Online gambling Sites in the usa � Compared Safe financial is an essential element of anyone online real cash gambling enterprise Here, discover ports, movies black-jack, and you may about wants from NetEnt, Microgaming, and you can Play’n Go Ideal 5 Safest Gambling on line Internet sites in the usa � Compared Most readily useful 5 Trusted Online gambling Web sites in the us � Opposed Dependence on Certification When choosing a safe Into the-range gambling enterprise Baccarat – since the shown regarding the Seymour toward 1897