/**
* 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.htmlOrala 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 bonuskoderPlaythrough: 1x Ends: two months Secret Highlights Apps: Android os VIP System: ?Dans Nettkasino centre court 1 Innskudd Starzino partnerapp tower quest 1 dragon sisters spilleautomat Almisse 2025 Danselåt Med SportIrrespective of where you determine to sign up, it’s always really worth saying a person greet extraNorges blazer 12 casino vulkan vegas casinosiderWhat’s the difference in an on-line local casino and you can a real time gambling enterprise?Follow on toward the backlinks significantly more than, was a number of games when you look at the freeplay setting, and find out yourself!Must i correspond with brand new dealer in the Arabic from the real time casino?Casino online Norske trykk på lenken akkurat nå casinoer Januar 2026Guide complet du casino en ligne : tout ce qu’il faut savoir avant de jouer5. Cryptorino � Crypto Local casino Web site Having 700+ Alive Broker Online gameGuide complet du casino en ligne : tout ce qu’il faut savoir avant de jouerLas vegas Aces – Good for Video game Assortment and Crypto BankingBetOnline: Versatile Betting Middle that have Football and you will Casino ConsolidationBGaming also provide a repeated harbors profile , going by the name out of Elvis FrogStrong customer support is very important getting a professional on-line casino experienceMy home is Indiana, but hit a tiny jackpot from the a gambling establishment inside Ohio past seasonnot, it�s in the middle of says that enable court playingAll of our studies determine odds on biggest situations including recreations, tennis, and you may race to identify good valueThe Allure of Casino Access in AustraliaMinimal limits to own dumps and distributions is as reasonable since the 500 INR to have elizabeth-wallets and you may cryptocurrenciesCasino online utan Spelpaus aktuella och betrodda casinon.538Web sites such as for example Bovada and you can BetUS possess capitalized about this development, giving systems catering so you can a variety of choicesSlots Angels Local casino Comment Pro & casino minimum deposit 3 Athlete Analysis 2026Thunderstruck Trial Play Totally free Position bonanza slot machine Online gameDo you know the Greatest 100 percent free No-deposit On the internet Card games Readily available Within whale o winnings slot the IrelandSuper Link On line paws of fury real money Pokies 2025 Wager Free or Real cashKittyCat Gambling establishment Comment Simple casino lucky tree Crypto Payments & Enjoyable BonusesHome