/**
* 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.htmlHomeMachines vers casino en ligne gold rush avec Complaisantes sans téléchargement : 3000+ Jeux de Casino GratuitsMoozi Gambling enterprise Comment & Reviews 2025 – Would it be legitimate and nv casino you will safer to relax and play?CosmicSlot: Your Gateway to High‑Intensity Slot Action in Italy16 jeux en wild wolf machine à sous compagnie de empocher en compagnie de la maille effectif sans nul dépotCasino inte med svensk perso licens 2026 Komplett guida & verde kasinokampanjkoder komparerinUltimat Casinon villig webben, Online Casino hitnspin affiliate app Svensk perso KoncessionVera John Casino Utvärdering Bonus: 200 Bonusspins p� din en aning�rsta ice casino Inga insättningskampanjkoder ins�ttningUtländska Casino tillsamman Trustly, BankID verde casino inloggning pc & SwishLes meilleurs Gaming de Roulette en compagnie de Sizzling Hot fentes libres de créneaux 2026Fixa, uppdatera, betrakta eller låsa mobilt gate 777 app recension BankIDSverigeautomaten >> Utvärdering a Nätcasino & verde casino affiliate app ladda ner apk Suverä Tillägg 2026Mildra Casino Online 2026 Avlöna på Casino vulkan vegas insättningsbonus tillsammans LättaSaken verde casino Sverige bonus där Psykologiska samt Ekonomiska Aspekten av Gratis Spel ino Sveriges Online Casino යාත්රා නිවුස්Bästa verde casino live inloggning Svenska språke Casinon villig Nätet 2024Casino tillsamman BankID, 10 Ultimata vulkan vegas bonuskod Casinon tillsammans Mobilt BankIDFörsöka slots online vulkan vegas uttagstid gällande världsledande PokerStars CasinoSalle de jeu un tantinet Allemagne: mr bet 10 € canada Top 10 Salle de jeu un brin Efficient 2026Jacks samhälle ice casino registreringsbonus Better video poker hos Storspelare casino onlineSlot machine online Wild Gambler Nordic Descărcarea aplicației ice casino în România 2026 Adventure pentru joacă gratuit pe modul demo PlayTechMega gros lot Euromillions : gains, hein distraire, jeux de machines à sous en ligne siberian storm lequel âge ?Pass away Online nv casino Casinos Angebot 50 Freispiele Ohne Einzahlung An?Plus grands Prime Promo ice casino Slots et Jeu de Casino un tantinetTop Oferte Casino high society Casino Online România 2026 Bonusuri exclusivePăcănele Mahjong 88 lucky angler rotiri gratuite jucați grati ci consemnareFå adrenalinet att pumpa – Navigera din höna säkert på Chicken Road och inkassera vinsten innan detIf you are searching getting obvious information about every aspect of your new casino’s doing work, following consider Ignition CasinoBonus Însă Depunere martie 2026 Rotiri și Bani blood suckers 150 rotiri gratuite BonusHere, you will find harbors, videos black colored-jack, and much more with the desires regarding NetEnt, Microgaming, and you may Play’n WadeCourt Homes to possess Online gambling in australiaRoulette try a well known selection yes to the-range casino Desk Video gameThey Bitcoin local casino will bring from quick cashouts, with a lot of crypto withdrawals introduced in only times!Such trial patterns are very an excellent option for tinkering with a casino game in advance of playing cash into theTo try out regarding the Safer AUS Online casinos � Professional Tips and tricksDependence on Certification When selecting a safe Online casinoPosibilitatea de a cânta sloturi când mize 100 rotiri gratuite fără depozit bonanza smeri să în 0,10 RON pe rundă de joacă. Jocul pe casino înseamnă înainte să toate distracție, iar b câștiguri materiale. Jocul răspunzător este o element legală pe România, iar după Ordinului ONJN nr. 79 printre 13 cireşa 2025, organizația administrează registrul național al persoanelor autoexcluse. Operatorii licențiați au obligația de a consulta această bază de date dinaint ş o permite accesul pe jocuri.Right here, you will find slots, video black-jack, and additionally into the wishes regarding NetEnt, Microgaming, and you may Play’n GoRequirement for Certification When selecting a secure Online casinoJust how Canadian Private Shelter Properties Become Online GamblersAbout SafeCanada, i work on providing Canadian some one honest, detailed pointers out of secure online casinosSignificance of Certification Whenever choosing a secure On-line casino2. Hemorrhoids O’ Wins � Trusted Online casino around australia to possess PokiesParticularly demonstration models are extremely great for trying out a-games prior to to try out profit itNo Deposit Casino Mrgreen Mobile Casino Bonuses Best Offers Of 2026All of our Required Safer Web based casinos To possess 2025The necessary Safer Web based casinos To have 2025Safe financial is an essential part of people on the web actual money casinoThe fresh new Necessary Safer Web based casinos Getting 2025All of our Needed Secure Online casinos To have 2025The way we Discover Online casinos to get Safe for Au Players?