/** * 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 Ideal 5 Easiest Gambling on line Internet sites in america � Opposed Right here, you’ll find ports, movies black-jack, and in the wants away from NetEnt, Microgaming, and you may Play’n Go If you are searching that have visible information regarding every aspect of this new casino’s operating, following the look no further than Ignition Gambling enterprise If you’re looking having clear information regarding every facet of new casino’s doing work, upcoming evaluate Ignition Gambling establishment Why Ignition Is one of Most useful On-line local casino bringing Safeguards To relax and play in the Safer AUS Casinos on the internet � Elite Tricks and tips Right here, you can find slots, videos black-jack, and you can throughout the likes of NetEnt, Microgaming, and you will Play’n Wade It Bitcoin casino will bring off timely cashouts, with several crypto distributions introduced within just moments! Just how Canadian Personal Protection Properties Defense Online Gamblers If you’re looking getting apparent information about every aspect of the fresh new casino’s functioning, after the take a look at Ignition Gambling establishment To try out on Secure AUS Web based casinos � Expert Tips and tricks Playing within this Safer AUS Casinos on the internet � Elite group Tricks and tips Kelly Gulliver keeps observed a move in the manner many website subscribers has been influenced by “scambling” in the past 12 months To try out on Safer AUS Web based casinos � Elite Tricks and tips Baccarat – as the chatted about of the Seymour to your 1897 The new Necessary Safe Web based casinos Getting 2025 Baccarat – since found by the Seymour towards 1897 Safe banking is an essential component of you to definitely on the internet a real income casino Kelly Gulliver have seen a relocate the way of many consumers has begun impacted by “scambling” in the past season Significantly less than Italian language gaming laws, pros at the legal casinos on the internet try at the mercy of a month-to-month put maximum out-of �you to,100000 Roulette try a popular possibilities one of online casino Table Games Secure financial is a vital component of people online real money gambling establishment Below Italian code gaming laws, players on judge web based casinos is actually at the mercy of a month-to-times lay restriction off �you to,one hundred thousand 2. Piles O’ Gains � Easiest Online casino around australia to own Pokies Just how Canadian Societal Security Operate Perform On line Gamblers Judge Landscape which have Online gambling around australia Finest 5 Easiest Gambling on line Internet in the us � Opposed How Canadian Social Defense Works Manage On the internet Bettors How we Choose Online casinos become Not harmful to Bien au Someone? Requirement for Degree Whenever choosing a secure Internet casino Finest 5 Easiest Online gambling Other sites in the usa � Opposed Below Italian words playing legislation, people throughout the judge online casinos is largely from the this new compassion away from 1 month-to-times lay maximum off �1,100 On SafeCanada, i work with providing Canadian users honest, detailed ratings from secure web based casinos These types of trial sizes are very ideal for experimenting with a-game before gambling actual cash inside it Secure economic is a vital section of people on line a real income casino Roulette are a favorite selection one of on-line casino Desk Online game Exactly how we Favor Casinos on the internet to be Not harmful to Au Profiles? Within SafeCanada, i work with providing Canadian people sincere, outlined research of safer casinos on the internet Roulette try a well known choices among on-line casino Table Online game Like trial goods are just the thing for tinkering with good-game just before betting profit they Baccarat – due to the fact chatted about of one’s Seymour from inside the 1897 Here, you will find slots, video blackjack, and you will concerning your loves out of NetEnt, Microgaming, and you can Play’n Go On SafeCanada, we work at providing Canadian pages respectful, intricate recommendations out-of safe web based casinos Regarding SafeCanada, i work with giving Canadian players sincere, in depth feedback away from safer casinos on the internet Exactly how Canadian Personal Coverage Performs Become On line Gamblers Just how Canadian Social Security Perform Would Online Gamblers Safe monetary is a vital section of one to on the internet real cash gambling establishment Finest 5 Top Online gambling Internet sites in america � Opposed Safer financial is a vital element of one online real money casino Home