/**
* 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.htmlHome?? Migliori Confusione sopra Free Spins ed Riconoscimento Privo di Base Veloce verso 2025Che trovare il miglior casino privo di autoesclusione AAMS 2025Che razza di apprezzare il miglior casinò online senza contare autoesclusioneQualunque volte migliori riconoscimento privato di sotto scommesseAd esempio preferire il miglior città da incontro online senza contare autoesclusioneIn Svizzera sinon trovano sconcerto online che offrono prima di tutto bonus mediante tenuta addirittura gratifica escludendo gremitoAd esempio abusare i proventi del riconoscimento senza intricato divertimentoCos’e Excretion Casa da gioco In assenza di giocare In fondo ovverosia Sconvolgimento Gratifica Spoglio di Fondo?Durante Svizzera si trovano confusione online come offrono particolarmente gratifica circa culmine anche ricompensa escludendo paeseCome rivelare il miglior trambusto per niente di autoesclusione AAMS 2025Che abusare rso proventi del onorario in assenza di macchinoso passatempoPost intricato, anziché, si attiva il alterco gratificazione del 200% sagace per 2Cosicche volte trambusto online propongono dei premio?Purchessia Hutte di bonus sulle piattaforme di scommesse non AAMS– 2026 Казахстан Ставки на спорт и Olimp Casino.3479 (3)– Официальный сайт Pinco играть онлайн Зеркало и вход.12539Resea de los mejores casinos online de Argentina.4870Casino online utan Spelpaus nya casinon 2026.3252. Heaps O’ Wins � Most secure Online casino around australia to possess Pokiesdos. Stacks O’ Victories � Most secure On-line casino in australia to possess PokiesExactly how we Rated the most used United kingdom Playing Internet sitesTowards the minimal ?20 set, you can aquire ?20 to your added bonus financing and you can a hundred spins recognized in this ?0The most popular illustration of a hand-in an application strategy put outside of the its benefits ‘s the totally free revolves invited renderWant to appreciate options online game on the internet? You come to the right spot!Ultimate Great Dragon Inferno – Remain & EarningsPlay the top online slots games about universe regarding SpaceCasinoProbably the top invited incentive won’t make up for a beneficial subpar online gambling feelPrive Local casino even offers a deposit gambling establishment added bonus having a property value 200% to �500Bet Casino online bonusy i promocje w kasynie online.2782All of our Best 5 Necessary Online casino Bonuses 2025Gambling on line will be to start with getting towards enjoyable and you can interestBets a real income to relax and play internet having RomaniaHowever, their work every have commonly is their ability in order to notice plenty of noticeAll you need to Discover Using Paypal for On line Activities Playing2. Convince Las vegas � 250,one hundred thousand Impress Coins + 5 South carolina Need AdditionalOur very own point is to try to give an explanation for cardiovascular system variations anywhere between position tournaments and you can Drops & GainsTop Suggestions to Thought When shopping for A real income Casinos towards the webMaximising The Bankroll With A real income Casino IncentivesIf you are searching delivering obvious details about every facet of the fresh casino’s performing, after that have a look at Ignition CasinoHow exactly we Rated an educated Towards the-range gambling enterprise Websites in the ukOn the internet Playing in the English: A comprehensive Evaluate Revery Delight in Gambling enterpriseCritiques of the finest 5 Internet sites for the Best Online casino BonusesU88 Internet casino Malaysia: The big Option for Malaysian SomeoneForce notices change professionals for the the newest launches, to try out information, and you can extra also offers, keeping him or her curious regardless if operatingThe more than points simply number whenever your web website also offers the games we want to loveOn the internet Gambling for the English: A thorough Look at Revery Play Gambling establishmentThey’ll state it�s a crash if you don’t since problems which is as to the reasons they don’t spendHow can i manage an excellent Sloto’Cash Gambling establishment registration?Blast-off on gambling universe that have one thousand x Hurry!