/**
* 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.htmlHomeRoulette is a prominent selection certainly on-line casino Table Online gameHow to Like a secure Into-line casino in australia?Greatest Real time Casinos online Wager Actual With Live PeopleOur very own Necessary Secure Online casinos Providing 2025Eye of Horus für nüsse verhalten and Echtgeld verwenden 太田電子 新しいモノ作りを創造する会社Right here, discover slots, movies black-jack, as well as on the new wants regarding NetEnt, Microgaming, and you will Play’n WadeGorgeous Spread out Pokie Wager 100 percent free & Realize OpinionBaccarat – as displayed on the Seymour for the 1897To relax and play on Safe AUS Web based casinos � Specialist Tricks and tipsТаза бағалы металл позициясы Толығымен тегін Gamble and Comment 96 44 goldbet қолданбасын жаңартуды жүктеу % RTPThe Requisite Safe Casinos on the internet To own 2025If you are looking to possess clear details about every factors of one’s latest casino’s working, after that check Ignition Local casinoBeste Live Blackjack Online Casinos within Land der dichter und denker 2026Étudiez la tête buffalo blitz fentes libres de créneaux palpable des jeux de tunes un peu en peu de tempsFrom the SafeCanada, we focus on providing Canadian professionals sincere, outlined analysis regarding secure casinos on the internetHow to choose a safe Internet casino in australia?Baccarat – just like the told me from the Seymour into the 1897Hot shot Casino Slots Obtain & Wager Totally free Right hereBetter 5 Easiest Gambling on line Sites in america � OpposedSuch as for instance demo products are very best for tinkering with a beneficial-game ahead of gaming actual cash to theEye of Horus Erreichbar Spielsaal Gratis & qua Echtgeld vortragenIdeas on how to Favor a secure On-line casino around australia?Best Live Casinos online 2026 Most readily useful Us Alive Gambling enterprisesdos. Hemorrhoids O’ Victories � Safest Internet casino in australia getting PokiesIt Bitcoin local casino produces terms of punctual cashouts, with plenty of crypto distributions setup just minutes!Official Site UkRoulette was popular alternatives certainly online casino Table GamesMost useful Live Casinos online Gamble Real time Specialist Video game within the 2026To play from the Secure AUS Web based casinos � Expert Tips and tricksGorgeous while the Hades Energy Blend ️ Clover Bingo ️ 96% +ten,000xOnline Kasino Provision 2026 Spielsaal Maklercourtage AbmachungExactly how we See Web based casinos as Safe for Au People?Most readily useful Real cash Ports to experience into the 2026 Discover Most readily useful Slots On lineLegal House having Gambling on line in australiaMost useful Online slots games the real deal Money Better Game and Usa CasinosIf you are searching bringing visible information about every aspect of the brand new casino’s performing, following check Ignition Local casinoTop Online slots games for real Currency at On-line casino Sites & ProgramsSignificance of Certification When selecting a safe Into the-line casinoBetter Online slots games 2026 Most useful A real income SlotsSuch demonstration goods are most ideal for experimenting with a game title ahead of betting cash in itReal cash Harbors Play Slots in order to Winnings A real income at Most useful Usa Gambling enterprisesExactly how Canadian Personal Safeguards Jobs Safety Online Gamblersgratis vortragen bloß AnmeldungExactly how Canadian Social Defense Work Become On line GamblersTop Online casino games On line one Spend Real money with a high ProfitsHow to Bush, Build, and Look after the Holly TreeHow to Favor a secure Toward-line local casino in australia?Free Casino games That Pay A real income With no DepositSiberian Violent storm бейне ойын автоматы: IGT-ден көңіл көтеру goldbet қолданбасы 2026 үшін тегін ойын автоматы бейне ойыны