/**
* 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 TVhttps://validator.w3.org/feed/docs/rss2.htmlHomeThink of – easy and fast deposits was fundamental, but reputable earnings are what it is numberSouth Park Free Slot Belzebu Play NetEnt Slots for Atual MoneyWestern european roulette provides a single no, causing a lower household edge of 2Queen Of Fire Belzebu Play Free Slots at Great uma vez queSlotsandCasino even offers multiple on the web roulette online game, catering to both novice and you will knowledgeable professionalsan hour or so piece controversially preferred good fresh fruit position info spiked by CBS Profile writer-in-direct fifty dragons $1 place Bari Weiss at some point airs Keller Williams Rub Medication & Reiki Energy RecuperationFor that reason, every single personal solution with this checklist might not attract yourSo if you visit a brand name because of us, we are able to be certain that a secure and you will fun experienceFish Road – Quick‑Hit Multiplier Thrills on the Oceanic PathCalm down and loosen up playing online gambling, a fun, relaxing activityEssentially, you’ll finish the confirmation techniques in advance of requesting a detachment to avoid waitsWild West Gold Slot uma vez que Rodadas AcessívelIn interior partea de sus acestei pagini faci gasi a oferte in locul depunere 2026Everyday 100 % free twist bonuses and you will slot-particular cashback has the benefit of serve faithful position participantsAfla?i cum ai facut tambur gratuite fara depunere on PariuriPlus ?i exact cum po?i retrage posibile shell out!It has become the leading online casino real cash having Canadian users due to its shelterCool Fresh fruit Position Gamble On line Free of charge and you will Win Real cashOur list has web sites that will be totally registered, regulated, and you will assessed by all of our advantagesOfertele de stimulent in schimb depunere au devenit populare unul dintre jucatorii din cauza cazinou cu privire la RomaniaJust the ?twenty three minimum put gambling enterprises you to definitely pass every step build our checklistLower lowest deposit gambling enterprises in britain create on the internet gambling a great deal more accessible and you may convenient50 Free Spins No-deposit Greatest 2026 registration also offersWhich is used for participants just who lose playing because recreation and you will funds accordinglyBut not if it has many invisible conditions otherwise impossible-to-see wagering conditionsThe research comes with checking and this commission procedures service ?5 placesten Greatest Real cash Internet casino Web sites You inside the 2026 Ministère de los angeles santé publiqueWithdrawals processes inside era, which have PayPal offering exact same-big date choiceBut really, be aware-possibly short financial investments incorporate brief returnsDebit notes are a firm option for gamblers claiming a casino register extraGreatest Zimpler Gambling enterprises 2026 Gambling enterprise Sites which have Zimpler RepaymentsWhen you’re reduced put gambling establishment web sites is actually developing well in popularity, they’re not an easy task to locateMecca Casino Deposit Extra Render March 2026: £20 and you can 50 100 percent free SpinsAnd more than significantly, it is registered, safe and legal in the ukPer underwent hand-towards analysis and put verification, video game access verification, and you can withdrawal handling away from small stabilityWizard From Opportunity ᐈ Guide to Casinos on the internet & Online casino gamesOf many operators give many different table game, together with black-jack, roulette, baccarat, and you can electronic pokerFinest Casinos you to definitely Undertake Skrill Approved by Advantages & PlayersFully licensed because of the UKGC, they guarantees a safe and you will reasonable betting environmentFinest Real money Online slots games playing within the 2026Customers need assistance instantly, the fresh new reduced the brand new impulse the brand new longer they will utilize the websiteBetter On the web Slot Websites: Better Slots the real deal Currency which might be Safe inside Canada 2026Such things ensure that the gambling enterprise are reliable, along with your private information and financing is secureNachfolgende Perron meine wenigkeit ist und bleibt uberschaubar aufgebaut, sodass respons dich direktemang wegen der Spiele klicken kannstPlay the better United kingdom gambling games today during the MrQAllySpin Casino: Vincite Veloci e Slot ad Alta Intensità per il Giocatore ModernoIf you are being unsure of from the a step, contact the fresh new casino’s customer service to have explanationHere in the brand new Hot-shot Gambling establishment you will provides an excellent whale out of a period Check it out today to see exactly what you could doing!The new Canadian Professionals Help guide to Vanilla extract Charge Local casino Places in the 2026Gamble 21,700+ Online Online casino games Zero Install