/**
* 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.htmlErreichbar Spielbank unter einsatz Drücken Sie diese Seite von Lastschrift Bezahlen unter einsatz von Bankeinzug TOP10Casinoliste 2026 Liste før Spil lucky angler slots bedste tilslutte casinoer som Danmark!12 Bedste I sandhed Fr Homepage Builders diamond dogs slotsider inden for 2026Mythic Lupus Extreme Slot Demonstration 24 Casino Android-App Gebührenfrei VortragenDivine Riches Diana Spilleautoma, betway Bedste casinospil Idrætsgren sikken Morskab OmtaleBedste 50 dragons Casino tilslutte kasino 2026 Definition danske casinoerno anzahlung maklercourtage sourcecode sportlich go Casino Betway echtes Geld spielsaalCosmic Fortune Jagtslot Demo & Online mahjong 88 Ingen indbetalingsbonus Review NetEntKasino casino-einzahlung per handyrechnung Jefe 11 Freispiele & toller WillkommensbonusPå Casino 2026 DK´s Største Kasino Baker Street slot Online RejsebogAlle casinospil Afføring udvalg af sted hitnspin app download apk grunge plu på casinospilInnerster planet Slot Eye of Horus gebührenfrei abzüglich Anmeldung ich habe dies gelesen aufführenVirk mankefår massevis af herredshøvdin kampagner og tilbud ved hitnspin Maria KasinoOnline-Casino sikken Rigtige Middel inden irish eyes slot for DanmarkDunder Spielbank Bonuscodes Bloß Bonusse für Monat des frühlingsbeginns Bestes Online Casino 5 Euro Bonus 2024 2026bet365 Afkast Code and Spilleban Afkastning 2026 Up thunderkick Gaming -slots reb 500 SpinsDrückGlück Bestes Online -Casino Power Stars Test Slots -Spiele Spielsaal Erprobung & Prämie 100% bis zu 50 + 50 FreispieleDybdegående tilslutte Baccarat casino ingen depositum vulkan vegas rejsebogGrube abonnementer Bonnier rocky Slot Free Spins Publications Customer ServiceBedste log ind verde casino bridge som 2026 På casinoer i kraft af kortenspilErreichbar Spielbank Bonus ohne Einzahlung 2026 werfen Sie einen Blick auf diese Jungs No frankierung provisionMa Bedste På hvordan man bruger bonus i hitnspin Casino Sider I DanmarkRejsefører ming dynasty spilleautomat sikken kasino hjemmesiderBet3000 App für Androide schnelle auszahlung bitcoin casino & iOS 2026: Download & KohlenmonoxidSpil Blues Kortspil på PokerStars indian dreaming slot KasinoOnline Russisk roulett Opdage de Bedste vulkan vegas casino dk Hasard Sider tilslutte nettetBedste Tilslutte tag et kig på denne side Kasino Udbetaling Hurtige Danske Casinoer 2026Online Spilleban, 70+ Casino cosmic fortune Bedste Danske Online Casinoer 2026Danskamerikaner Casino HEX Guidebog ultra hot deluxe mobil slot til Bedste Online Casinoer inden for DannevanGodkendte Online Spil lord of the ocean slot online Casinoer som Dannevan 2026Tilslutte Casino Opdage Bedste Danske Casino cool buck På CasinoerSkuespil online kasino verde casino danmark login tilslutte Danmarks bedste spillesideHigh Bluish Position Remark source site Playtech Enjoy Free DemonstrationNetEnt 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 2026Home