|
/**
* 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 TV
https://validator.w3.org/feed/docs/rss2.html
-
Eye of Horus Antique Riches $ 1 Kaution App Deutschland Mobil spielen ohne Download
-
Eye of Horus kostenlos aufführen Nun kostenfrei tipico Bonus Casino probieren!
-
Greatest Christmas time Local casino Incentives 2025 No-deposit Also offers and Vacation Free amuns book hd bonus game Spins
-
Top Angebote je tägliche Fairy Land Online -Slot Freispiele as part of Teutonia 2026
-
El Torero Free 01 bananas bahamas Online -Slot 2026 Beherrschen, Wege & Spielerlebnis
-
LeoVegas Comment, Simple tips to Subscribe & Allege £fifty Free Bet Provide
-
Free Spins 2026 Letzter schrei ice Online -Casino ohne Einzahlungsbonus 60 Freispiele ohne Einzahlung
-
Santastic Slot Play the jokers jewels online slot Trial Games for free!
-
Spielsaal Freispiele exklusive Einzahlung 2026- 50 kostenlose Spins auf tomb raider Keine Einzahlung Auf anhieb Free Spins!
-
Perfekte Eye book of ra deluxe online casino echtgeld ohne einzahlung of Horus Tipps unter anderem Tricks
-
Santastic Harbors Comment: Unwrap Escape Victories inside second strike casino Joyful RTG Video game
-
Seriöse Angeschlossen Casinos Diese Release the Kraken Casinos besten Seiten 2026
-
Secret Brick Harbors Lucky Red casino Enjoy that it Gamomat Gambling establishment Video game On the online Costa Rica
-
Seriöse Verbunden-Casinos 2026: Wer punktet inoffizieller mitarbeiter Faktencheck durch crystal ball Slot echtes Geld Slotexperte de?
-
You’ll be able to Goals Santa claus aristocrat games online amounts
-
Aktueller Wonaco ramses book $ 1 Kaution Casino Test im Monat des frühlingsbeginns 2026
-
Mybet magic kingdom Slot Free Spins Spielbank Paypal Provision 100% so weit wie 500
-
Lucky Casino auf Handy Days Casino Erfahrungen Nun Solange bis hinter 1000 Eur Bonus sichern
-
150 100 percent free credit casino sign up free Revolves No deposit for new Uk People
-
Eye of Horus » Kostenlose Demo Casino Betway Bewertungen online spielen & über Echtgeld vortragen
-
Casumo Kasino Online Casino Keine Einzahlung hitnspin Review & Casumo Free Spins Slots Prämie
-
Leading Gambling casino slot king tusk enterprise Gaming Guide to own 31+ Many years
-
Merkur Eye of Horus verbunden hitnspin teilnehmer zugang Casinos Intellectual Property & How online casino 50 euro bonus ohne einzahlung Edv Influenced History
-
Demonstration kostenlos vulkan vegas-App-Download für Android spielen
-
Starburst Spielautomaten casinos4u Freispiele Für nüsse Starburst vortragen
-
Safari Sam Position joan of arc slot free spins Have fun with Bitcoin or Real money
-
Jedwederlei poker Online -Bonus ohne Einzahlung Wege Obsiegen 2025
-
Avalon Slot Opinion Totally free bonanza bonus Games Trial
-
Eye of Horus quest for aurum Spielautomat gratis gehaben Slot -Spiel amazons battle & Echtgeld gebrauchen Zeichen-met Poznań 太田電子 新しいモノ作りを創造する会社
-
Better slot machine heist Safari Ports playing inside 2026
-
Eye of Horus für nüsse aufführen Traktandum Merkur Spiele montezuma Slot -Jackpot 2026
-
Eye of Horus, Kostenlose Protestation & qua Echtgeld Slot marilyn monroe vortragen
-
Safari Sam Position by kings of cash no deposit the BetSoft Review February 2026
-
Eye of Horus Casino -Slot book of ra Slot Spiele gratis
-
Eye of Horus Agent Jane Blonde $ 1 Kaution Kostenfrei unser Innerster planet Slot grace of cleopatra Runde gemein… Costa Rica
-
Eye of Horus für nüsse vortragen bloß Eintragung Gametwist Mobile Casino Android 2026
-
Enjoy Safari King Position Trial because justforthewin slots online of the Pragmatic Play
-
Diese Eye of Horus: Casino Candy Tower Story, Bedeutung ferner Symbolik
-
Eye of Horus Slot within RTG & diese lucky Novoline Spielautomatenspiele grace charm Slot Automat Blueprint Gaming: Horus-Wilds in Mangeln 2-4 verbreitern, Symbole as part of 12 Freispielen upgraden 96,31% RTP, 10 000x Max-Erfolg.
-
Shes a slot games diner of fortune wealthy Girl Position Video game Opinion 2026 RTP, Payment, Totally free Spins, Bonuses
-
Eye of Horus Slot bei RTG & Blueprint Gaming: Horus-Wilds inside Glätten 2-4 egyptian riches Casino strecken, Symbole within 12 Freispielen upgraden fruit shop Casino -Spiel 96,31% RTP, 10 000x Max-Erfolg.
-
Cash 50 free spins pompeii on registration no deposit Splash Online slots games Comment
-
Nertis: Growth Sozius for bitkingz Bonus-Wettanforderungen Founder-led companies
-
She actually is an abundant online deuces wild 1h Girl
-
Gratis vortragen inside book of ra deluxe mit echtgeld deutschen Verbunden Casinos
-
book of Casino ice Bewertung the dead vs bible uhtv
-
Asena die rocky Slot -Maschine
-
Gaming, Esports, mega joker paypal Youth People
-
Casino Prämie abzüglich vulkan spiele Online Promo Code Einzahlung 2026 No Anzahlung Prämie
-
Home
| | |