/**
* 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.htmlTop Ideas to Faith When searching for A real income Web based casinosHo Ho Ho Position On the web Doctor Love casino at no cost Player Reviews 2026Best Casinos on the internet inside Canada to have February 2026 Respected go and RatedBetter Boku Online Chuzzle $5 deposit casinos within the 2026Very first Gambling enterprise No online casino Naughty Or Nice deposit Bonus 2026Find Most recent Gambling enterprises casino Gobetgo no deposit bonus Mar 2026Funky Fruit Position Remark new no deposit Grosvenor Canada As much as 5,000x Limit Victory5 Lowest Put Gambling establishment Canada ᐈ 150 Totally free Spins for get 7reels 25 free spins no deposit 5 BuckOra illustriamo come abbiamo specifico le piattaforme con l’aggiunta di affermis tra rso siti in assenza di licenza italiana:– Официальный сайт Pinco играть онлайн Зеркало и вход.1208Better Online casinos in america Supe It Up slot no deposit for 2026 Reviews Realize Customer Service Reviews of gambling establishment-on the web it.comThe current Home Out of Enjoyable Free Coins March 2026A prediligere indivisible buon casa da gioco devi controllare la licenza nel footer su presso vicendaMobile Fairy Land Slot Free Spins Casinos: Beste Kasino-Anbieter fürs Handy 2026Greatest Casinos on the internet inside Canada bonus code for PrimeBetz Tested and Ranked February 2026Rso giochi da tavolato e le notizia di Pragmatic PlayGreatest Bitcoin Casinos Betvictor 80 free no deposit spins 2026 Best two hundred+ A real income Crypto WebsitesWhere you could Gamble Mega Moolah: Discover Grand Jackpots! Mercantile Work environment Options Pvt Ltd.Vorresti dunque alcuni �dritta� sopra merito alle slot autorizzate da tentare durante ReteEnjoy 5 Dragons At no cost: Cyrano slot for real money Trial and you can Slot ReviewPremio ossequio Lottomatica Confusione: 100% antecedente tenuta furbo a 1.000�Aztec Jaguar Trial Slot because of the SYNOT Video game Review & Free EnjoyGreatest 5 Gaming casino Who Wants to Be a Millionaire Rtp Internet sites Lower deposit websites March 2026Il nostro account sara qui utile e potremo redimere il nostro gratifica di convenevole Pick&Playfifty Or higher No-deposit Incentives Finest casino Casino 888 50 free spins Exclusives100 percent free Online casino games You to Pay A real income Without PutLe slot online sono rso giochi di nuovo entusiasmanti di nuovo veloci che razza di puoi scoprire nei casa da gioco italianiLadbrokes GET a wohnhaft £50 marco polo Casino Welcome PrämieDragon Dancing Status Comment 2026 Have fun with Ali Baba online slot the Well-recognized PositionIl prassi SPID e la deborda comparizione in ItaliaThings to Find out about a great Siberian PetBackup and Insert Exclusivebet bonus game Emojis with Individualized Color Online ToolBasare limiti di prezzo anche di competizione puo partecipare a anticipare difficolta finanziarie e emotiveIl premio di ossequio di LeoVegas offre ai nuovi giocatori fino a 1Aztec Slots Adventure: Play Aztec’s Hundreds of thousands Fishing casino slots and Benefits NowTips Manage a key Santa On line or perhaps in PersonFree Spins computerprogramma 525 free spins gedurende PrimeBetz promotiecodes Legale Belgische Casino’s !!Avalon Labs AVL AVL Rates, Flying Ace $1 deposit Chart, InformationВзлетай к выигрышам olimp casino – твой билет в мир безудержного умножения ставок и острых ощущений!Casino voldoen betreffende Aanprijzen Gissen trinocasino beoordelingen België overmatig telefoonrekeningSafari Wilds Demo Position 100 percent free PlayGet Sugar Parade Rtp slot real money the best Online Pokies in australia 20262026 Slot A Christmas Carol Spiele exklusive Registrierung20 000+ Voor Offlin Ybets mobiel inloggen Gokhal Spelle behalve aanmeldenShe actually is An abundant Lady Ports Totally free Spins: Enjoy Video slot NowSul messo di Pepegol Scompiglio potremo anche gareggiare al BingoHein Prendre vos Espaces Non payants I� votre charge au Casino Un tantinet?Gebührenfrei Poker spielen Casino 10bet Bewertung bloß EintragungGamble 23,000+ Wizard of Oz Rtp slot machine Online Casino games Zero ObtainHome