/**
* 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.htmlCalificaciones de casinos en lnea en Argentina.4731 (2)Calificaciones de casinos en lnea en Argentina.4600Los 10 mejores casinos online de Argentina.4617Pin Up – Azrbaycann n yax kazinosu Rsmi sayt.9306Pin Up – Azrbaycann n yax kazinosu Rsmi sayt.8968Pin Up Casino Azrbaycan.8790Vavada Online Casino felhasznli lmny dizjn s kezelhetsg.1890Μη Άδεια Καζίνο στην Ελλάδα 65Pin Up Casino Onlayn Azrbaycan.10082Leon .1214Najlepsze Kasyna Online w Polsce w 2026.11245 (2)Sky Crown Casino Australia Complete Guide to Playing.2958Rangliste over online casinoer uden licens i Danmark.4569Rangliste over online casinoer uden licens i Danmark.4005Pin Up Casino – Azrbaycanda onlayn kazino Pin-Up.20461Najlepsze Kasyna Online w Polsce w 2026.2177Guide complet du casino en ligne : tout ce qu’il faut savoir avant de jouerGuide complet du casino en ligne : tout ce qu’il faut savoir avant de jouerPin Up – Azrbaycann n yax kazinosu Rsmi sayt.12398 (2)Pin Up Casino – Azrbaycanda onlayn kazino Pin-Up.24595 (2)Pin Up Casino Onlayn Azrbaycan.12290 (2)Parhaat nettikasinot Suomessa suosituimmat kasinot verkossa.1399Kasyno online jak wybra najlepsze w Polsce.389Najlepsze Kasyna Online w Polsce w 2026.421Najlepsze Kasyna Online w Polsce w 2026.26747Pin Up Casino – Azrbaycanda onlayn kazino Pin-Up.25999 (3)Paras nettikasino Suomessa vertailu parhaista pelisivustoista.1009Orala steroiders roll för att optimera bodybuildingträningTraktandum Bewertete Echtgeld SeitenElonBet Casino and Mobile Gaming: Quick Sessions for Busy PlayersSvenska Online Casino Utan Spelpaus bsta alternativ fr svenska spelare.557Svenska Online Casino Utan Spelpaus bsta alternativ fr svenska spelare.400Roulette 50 gratis spinn fairytale legends hansel gretel ved registrering ingen innskudd på nett på edel penger 2026 Joik roulette onlineFree spins 2026 Sammenlign beste finn denne informasjonen her gratisspinn i NorgePlay Online Roulette Casino euro påslåt Hederlig Money: Rekord Casino Sites in 2026Less than, there are a table giving an introduction to a knowledgeable greeting bonuses available today at the various online casinos:Norges beste online casinoer bibel jackpot jester 50000 $ 1 Innskudd 2026Online Casino 2026 Sammenlign casinoer for vulkan vegas registreringsbonus nettNorsk 50 gratis spinn på tower quest bruksanvisningWinter Berries 100 fri flettverk ett fett almisse gonzos quest ett alle tiders spilleautomat ikke i eye of ra online spilleautomat bruk Yggdrasil!Another great added bonus well worth these are is the CS2 circumstances added bonusIt’s just not difficult to find real cash casinos, but it’s difficult to get unbiased reviews of them9 Beste Nettcasinoer 2026 Pengespill og Casino superlenny Ekte penger Reelle FormueCan also be Get: ? Sc Really worth: 1 Sc = 1 USD Redeem:: Bucks Prizes, Current notes MinuteVenice live forhandler online blackjack Magic Slot with loads of Akkvisisjon FeaturesOregon betting internet participate new professionals having a welcome extraBruksanvisning for hver Bh Slot hot seven Casinoer 2026In the event the this type of concerns was in fact bothering your, take a look at after the Faqs getting solutionsDisposisjon undersøk dette nettstedet avbud casino addert bonuskoderHome