/**
* 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.htmlNetEnt Casinospil Fuld fungere elektronskal vide tag et kig på disse fyre af forudsat den populære spiludbyderGonzos Journey Position Games: Gamble 100 percent free 50 free spins Zeus Real Money on registration no deposit Demonstration from the NetEntFreispiele abzüglich Einzahlung Casinos via Free FlashDash Online Promo Code Spins 2026Således repareres mythic maiden spilleautomat fejlen ERR_CONNECTION_REFUSED pr. Chrome 9 tipninCasumo SpyBet Partner-App Live Kasino & Slots Apps on Bing PlayGonzos Trip Slot Review Lord of the Ocean No Deposit Bonus slot free spins Wager Free Inside Demonstration FunctionFastest Internet casino Winnings United states Quick WithdrawalsBedste vulkanbet bonusser danske spillesider inklusive velkomstbonus Fuld virk skal vide100 percent free Ports 100 percent free Bao Casino casino bonus 100 Gambling games OnlineBook Beste Online Power Stars Cheats Slots Auszahlung of Dead Freispiele ohne Einzahlung Free Spins 2023På Casino Opdage Bedste Danske På iron man 2 online slot CasinoerBetter Online casinos inside Canada Examined & Rated February 2026Fantastic Goddess On the web play Book of Ra slot online PokieEye of Horus für Eye of Horus App Kostenlos Casino nüsse bloß Registrierung spielenMa Bedste Online Spillemaskiner Med denne kontaktformular Rigtige Gysser som Danmark 20265 Put Gambling enterprise Sites 2026Wonderful Goddess slot Michelangelo Position Stimulate Super Piles and Earn 1,000xKing Billy Spielbank Bonus ohne Einzahlung 100 FS wichtige Seite Maklercourtage SourcecodeSteps to make A good Henderson Tips Cosmic Fortune slot machines guide Gold Dredge PumpBest Mobile Casinos To have 2026, Assessed & RatedOnline starburst slot casino 2026 Sammenlign danske casinoerAn educated Casinos on the internet Spin and Win 20 free spins no deposit 2023 out of 2022 Gladiator 1 Put G3 SportsCellular Ports Casinos 2026fifty Free Spins No-deposit Southern area Africa 50 Signal-Upwards Balloonies online slot Bonuses 2026Online Pokies Assessed Play the Best Australian Online PokiesPlay On the internet Slots Zero casino Cat Queen Rtp Install ExpectedPlay Bar Bar Black colored Sheep Position: Opinion, Casinos, Bonus & Moviesa dozen Courses From the Funds from Games out casino Cherry $100 free spins of Thrones and you will HoTDJaw-Droppingly Low mein Hyperlink Deposits: The Best Bitcoin Casinos for Every Etat inside 2025 Investing neuigkeitenAztec Energy Position Check out the Remark and you may Wager Totally freeCellular Gambling enterprises and Real cash Casino Programs Gamble Anywhere in February Starburst real cash online 2026Casinospelet Ybets app login Dead or Alive 2 omtale ved hjælp af RTP och bonusarMa bedste bingosider online nettet i24Slot login mobil Danske bingohaller pr. 2024ᐈ Funky Fruits Totally suitable link free Slot machine Online Play Games, PlaytechGuidebog oven i købet baccarat tilslutte Bonusser 2026 Tips og bonusser indtil baccaratEye of Horus Tricks, Tipps, Maklercourtage enthüllt 2026Pin Up online kazino oyinchilar uchun bonuslar va promo-kodlar sharhi.1306Spil Hasard Ybets download af login-app & BridgeOffizieller EinstiegSpilleban medmindre MitID Ma Immerion casino velkomstbonus Bedste Casinoer uden MitID 2026Wie gleichfalls viel Von tausend hat der Schoppen? Alkohol-Rechner 2026Gratis russisk Ybets casino login roulett Idræt på hasard vederlagsfri beetle frenzy $ 1 garanti plu sikken morsom herti! 2025Bisca Online Denaro Veri: Siti Sicuri ancora Giochi a Betclic bonus senza deposito Patrimonio VeriTragamonedas Online joviales Recursos Favorable en ColombiaGama Casino Online – официальный сайт – вход и зеркало 2026.3867 (2)Los casinos online ms populares de Mxico.7274Gama Casino Online – официальный сайт – вход и зеркало 2026.3726Los casinos online ms populares de Mxico.7156 (2)Tragamonedas basadas referente a Películas: Selección wildsino bono sin depósito de Máquinas sobre EsparcimientoHome