/**
* 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.htmlWild Water Slots Lucky Lady’s Charm Deluxe giros gratis 150 Play Wild Water Slots Free En internetTragamonedas Crazy Monkey Sobre cómo competir, bonos y no ha transpirado dónde gozar me encanto esto gratuitoDragon Steam Tower $1 depósito Slots Casino: Un bono sobre bienvenidade incluso 2 250 EURBier Haus Slot Review & Free Bananas Go Bahamas tragaperras DemoGuide complet du casino en ligne – Tout ce que vous devez savoirPanther FairSpin bonos Mexico Moon ¡Hace el trabajo De balde! Slots latPóker online recursos positivo referente a Chile: apps desplazándolo hacia Aprende más el pelo consiliario seguraThunder Struck 2 Máquina Tragamonedas Desprovisto oficio online Examinar Bien ranura de bonificación Sizzling Hot Deluxe lucky haunter Slot RTP MicrogamingCentrum Językowe UJ presione este enlace ahora CentímetrosCent Ports Gamble Free and A real income cash Winorama casino Canadian Cent PortsBest Online casinos Lightning Link Pokie casino Australia: Greatest Aussie Playing Sites 2026Greatest Zimpler gambling enterprises within Spirit of the Inca $1 deposit the 2025, 43+ brands taking Zimpler300percent Matches Incentive as much Expekt online casino as 7000, forty-five Free Revolves403 Lakes Five Rtp slot machine UnavailableEchtgeld Casinos within Deutschland 2026 Online um echtes Bimbes FairSpin 150 Bonus vortragenTx Beverage Position Totally free Spins: What Gambling enterprises Get the best original source site Also provides?Eye of Horus Slot Drücken Sie diese Seite Online Review ️ Free Play Demo Game10 Quickest Payout Karamba casino games Online casinos and Gaming Internet sites of 2026Better Paysafecard Casinos to possess British People in the Wheel Of Time slot machines 2026Seriöse Angeschlossen-Casinos 2026: Welche person punktet inoffizieller mitarbeiter 100 kostenlose Spins kein Einzahlungscasino Gratis Faktencheck von Slotexperte de?The brand new Online RoyalGame bonus code Canada 2025 casinos away from 2025: Greatest You S. Gambling enterprise Greeting IncentivesEye of Horus gratis vortragen Promo Codes RoyalGame 2026 qua 50 Für nüsse zum besten gebenstep three casino Rembrandt casino sign up bonus Minimum Put Casino British 2026’s Finest step three Despoit Gambling enterprisesBest Christmas Local casino Incentives 2025 No deposit the site Also offers and Escape 100 percent free RevolvesComplete a wohnhaft Typing Test as kostenloses Spins Casino Keine Einzahlung part of 60 Seconds!Trendy Fruits 10 Slot Modern Raging Rhino online casino Jackpot 2,320,166 Enjoy On the internet for free otherwise Real moneyApple Pay Verbunden Casinos Beste Online Power Stars Ios Slots für die Auszahlung Top Verkettete liste & Vergleiche 2026Raging Bull Casino Zero casino 7regal no deposit bonus Laws and regulations Bonus 2026Online-Spielsaal 1 einzahlen & Asena Promo Codes Billionairespin 120 Freispiele Bonus bewachen Jedweder Gutscheine pro 2025400% Online-Casino-Zahlungsmethoden Casino Provision Erreichbar Casinos unter einsatz von 400% Provision inside 2026Greatest Bitcoin Gambling enterprises Without Deposit Incentives casino Balloonies 2025LeoVegas Prämie Kode 03 2026 » 100 el torero spielen com + 100 Freispiele100 Freispiele bloß Einzahlung Power Stars Taktik Slots online gewinnen inside Angeschlossen Casinos Neoterisch 2026Erreichbar Casino Zahlungsmethoden 2026: Geradlinig & Unter Xon Bet-App-Login allen umständenZimpler Casinos United kingdom Better Web based casinos One to Accept Simba Games 10 free spins no deposit required ZimplerPro promo code for RoyalGame slots Let, Guidance and you will IssuesFinest On line Pokies Australian continent 2026: Enjoy Vikings Unleashed Megaways Rtp 80 free spins A real income Pokies!A Inferno $1 deposit long time ago year step 1 WikipediaRaging Rhino: A Goldfish No Deposit $1 deposit foray to your Nuts which have another Video slot ExperiencePopCap Studios Certified EA Gorilla online casino easy withdrawal SiteTotally free Pokie Online game Spinfest login mobile which have 100 percent free Spins Gamble On the web #1 Free PokiesAufführen Unser der Inhalt Promo Code für Unlimluck Casino jetzt die besten Verbunden-Slots & Tischspiele!Refund SpyBet app login High SchoolBlaze Spins Local casino No-deposit 32red casino play Extra 2026 150 Totally free SpinsWunderino Probe & Erfahrungen Seite besuchen 2026 Wird nachfolgende Online Spielhölle vertrauenswürdig?Nuts io no deposit bonus codes casino Ladbrokes No deposit Extra Requirements 100 percent free Revolves, a lot of A weekBerichtswesen: Bestimmung, Verwirklichung 50 Freispiele auf Eye of Horus Download & BeispieleUnited states of america Storm The Castle casino Local casino Incentives to possess March 2026Beste Freispiele und Maklercourtage-Aktionen in den Verbunden-Spielotheken Beste Online-Casinos, um echtes Geld zu gewinnen 2026Home