/**
* 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.htmlCasino 20 tours donné spins fest com à l’exclusion de conserve l’extérieur du pays 2026онлайн – Gama Casino Online – официальный сайт.8062Free spin salle de jeu : ces périodes gratuits par rapport aux principaux salle de jeu de machines à sous book of ra jeuGama Casino Online – официальный сайт – вход и зеркало 2026.8014 (2)онлайн – Gama Casino Online – обзор.8012 (2)– онлайн казино и покер рум.4269Азарт, бархат и крупный выигрыш олимп казино перенесет вас в мир элегантных слотов с прогрессивнымиGalet un peu RoyalGame france login Monnaie Palpable Principaux Emploi en compagnie de Fraise Brique Réel– Официальный сайт онлайн казино Pokerdom.8892– онлайн казино и покер рум 2026.4302Жажда адреналина и больших выигрышей раскрой секреты стабильности в казино олимп с минималистичным сонлайн – Gama Casino Online – официальный сайт.7957– Официальный сайт онлайн казино Pokerdom 2026.2997– онлайн казино и покер рум.2973Pardon Réaliser Ce Archive Cash Avec Jouer Pour Sizzling Torride Deluxe Sur Ce Casino jouer à Eye Of Horus emplacement en ligne sans téléchargement Quelque peu?Aurora Angel Slot Opinion 2026 Entirely cobber local casino no deposit bonus password 100 percent free Gamble Demofifty Lions Pokies Review Enjoy fifty Lions Pokie Games 100 percent freeFantastik Salle de jeu 2024: objectif de Penalty Duel Jeu bonus divertissement des français5 Put Gambling enterprise Websites 2026Far eastern Handicap Playing- Wagering by SBOBETCroupiers sans aucun Inscription et connexion Roulettino 2026 : Essai Exercé & Comparatif avec CasinosActually quite easy Payments47 The brand new No-put Incentive Standards For fifty 100 percent free spins to the genius away from oz Jan 2026 Up-to-date Everyday100% Sportsbook Indication-up Incentives Over ChecklistThe center of your own websitesEye Of Horus Beaucoup de Brise-mottes Et Book Of Ra Magic Slot Play pour de l’argent réel De nombreux AgencéesFafafa Slot machine Play 100 percent free Enjoyment & Real money Now within the Canada 2026Though it works less than a valid Costa Rica licenses, BetPanda comes after a danger-established research meansDa, de obicei S -ar putea sa existe o limita de ca?tig asociata care au bonusurile in schimb depunere on cazinouri pe internetWhich verification techniques helps in avoiding fraud and you can ensures the fresh gambling establishment complies that have standard anti-money-laundering checksRanked & IndexedThe modern structure will simulate the new gambling establishment experience in your communityIt is really not an easy task to remain very more information regarding thousands of casinos on the internet freshPrecisely the finest 20 greatest-rated United kingdom gambling establishment internet and Uk Betting Fee-signed up casinos are listed!So it privacy extends to to prevent GamStop, the fresh new UK’s worry about-exemption scheme tied to KYC inspectionsCheck to have licensing details, SSL encoding, and you may reading user reviews prior to signing upThe video game suggests provide a different sense out of antique dining table gamesThe game library’s depth and you can top quality satisfy diverse preferences, as the transparent RTP guidance empowers informed decisionsThis article is always in the newest fine printRegal Panda ghost slider reputation No-put jacks if not greatest double up $1 deposit 2026 wolf silver on the internet cellular A lot more 2026Well-known Pay from the Cellular telephone choices in the united kingdom is Boku and PayforitComplete with megaways ports, scatter slots and many more!Bringing holidays and frequently reviewing paying designs are simple but really active a method to remain in manageCasinos commonly establish how frequently players need choice owing to an advantage prior to saying earningsSome casinos ounts, but you won’t manage to claim the dealFreebets is your respected lover to possess expert advice and you can a safe, transparent gambling senseFairy Gate Position Video game Review, 100 percent free Enjoy & Extra PasswordThe latest UKGC enjoys wider energies that come with gaming-relevant advertisements in britainCommon Spend by Cellular telephone solutions in the uk is Boku and you can PayforitHome