/**
* 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.htmlTest post titleShort the avengers slot machine Hit Slot machines 2025Lucky Harbors Applications on the internet 40 free spins 2025 no deposit GambleFree Good fresh fruit Machine Games: List of Finest Fruits Slots playing best slots real money for funSheep Moved Nuts Slot Comment 2025 100 percent free Play mr cashman slot machine TrialBitStarz local casino liberty slots casino Added bonus Codes Crypto Bonuses, No deposit Added bonus & Ongoing Rewards50 Free Revolves No-deposit Gambling enterprises Get United 7 monkeys slot for real money kingdom 2025Casino Freispiele bloß gladiator of rome Slot -Bonus Einzahlung Neue Kasino Free Spins30 Freispiele abzüglich Einzahlung Tagesordnungspunkt Casinos Bonanza Slot Online Casino 2025Deposit ten Rating 100 Free free slots uk 300 shields Spins Finest ten Gambling establishment Incentives United kingdomBuffalo King Für mighty kraken Slot Free Spins nüsse vortragen bloß Eintragungas part golden egypt Online -Slot of Online Casinos via Echtgeld vortragenVision Out of Horus 7 Totally free Revolves No-depositMultiple Twice Da Vinci double-bubble free 80 revolves Expensive diamonds Slot Remark & Totally free Delight in Extra چیدانه پلاس50 Freispiele bloß Einzahlung sofort ramses ii Online -Slot verfügbar inoffizieller mitarbeiter 2025Athena’s Magnificence The new Golden Time Demonstration Gamble Position slot game rockabilly wolves Games a hundred% FreeTwice Diamond Slot machine: Free Position Online online pokies real money game On the internet No InstallGreatest online play 50 lions slot online no download slots for real currency having unbelievable picture 2025Free Spins hvis ikke indbetaling 2025 Få øje på ma bedste i24Slot casino login tilbud her!Discuss Best Egyptian-Themed Harbors that casino Spin City casino have Super IncentivesThe brand new Year’s Day Gambling enterprise Bonuses 2025 Happier New-year!Chicago Gold Position: Enjoy 100 percent free Trial Slot by dead or alive mobile slot the Microgaming#step one Free online Social Gambling establishment FeelEmpower Your Passion Build a Thriving Community & Monetize Your Content with OnlyFans Strategies.Fortune Looking: Gold-rush Game from mega moolah slot free spins the DiceLab Gamble On linePinnacle for Android Free Application InstallEchtgeld Slots Diese besten Spielautomaten inside 2024 onlineŞansă pentru distracție Top 21+ cele apăsător bune jocuri de chef prep următoarea raclă comportament!JackpotCity Cassino é confiável? Apreciação Cassino JackpotCityBônus Cassino Pix, Código promocional 20 Giros dadoMelhores cassinos online com giros grátis 2025 Rodadas acostumado10 Melhores Jogue Highway Kings Pro Algum Real Açâo Sem Armazém Forex10 plus grands situation de blackjack en Bonus de machines à sous vulkan spiele ligne du appoint profond 2025Columbus appareil a dessous jeter un oeil sur le site offert pour Greentube avec 9 bandes de credits RTP en compagnie de N AvaitColumbus accessoire vers dessous offert de Greentube en compagnie de 9 lignes de credits RTP Dépôt de casino pay by phone de N JoueCasino Gratification Sans nul Classe 70 Direct Offres désintéressées curieuses & jouer release the kraken recouvrablesAllez en Accessoire pour Dessous Gates of OlympusEssayez À 100 Mademoiselle Donné- Le Chance Florale Une !Vérification avec recevoir pour la maille : merveilleux deux +20 de votre point de vueMožnost, igranje, linije za Uk Unlock 2025: Scottie Scheffler je največji favorit Opena, medtem ko je bil leta 2015Finest On the web Baccarat Betting in the Malaysia + Real time Baccarat SitesNajvečji teniški naslovi 2025 Najnovejši profesionalci, odkleni nas, odkleni turnir in PGAbet-at-home részletes ajánlások Minden, amit a bet-at-home-ról tudni kell888Sport Ontario alkalmazás letöltése 2025: Mobiltelefonon keresztüli sportfogadásTest post title$5 Deposit Gambling establishment NZ: Deposit $5 get a hundred 100 percent free Spins 2025A legjobb e-sport fogadási kiadvány 2025-re: Hogyan kezdjünk hozzáArbitrázs és fedezeti fogadási kalkulátorPaddy Energy Android és iOS alkalmazás letöltése és telepítése Paddy Energy mobilalkalmazáshozHome