/**
* 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.htmlOnline Casino GuideCent Ports On the web: ten Finest Game and you will Where you can Enjoy Him or slot Michael Jackson Rtp herSlot tournaments are an easy way to include some extra towards moneyVälkommen åt vårt svenska Bingo & Casino Online Ino Bingo comAs to why Purchase the Cell phone Local casino to tackle Las vegas Harbors?Casino minsta insättning Flamma insättningar på 50 sund FörteckningSlot machines Having Added bonus Online Microgaming games game: Play Totally free Position Online game Bonus Rounds?? Ein- oder Auszahlungen � begrenzt geregelt je BrdAudits make sure gambling enterprises play with company-owned wallets, not personal ones, to guard professionalsCasinostugan utvärderin: Ett djupdykning i digitalt spel med svensk person kvalitetVirtual casino online payment methods Dice and Money FlipCasino inte me konto 2026 Försöka inte me intrikat registreringOver the past couple weeks, I was travel on You, taking-in says such Michigan and you will Rhode IsleCasino utan svensk person koncession: Vägledning till suverän casinon inte med SpelpausTotally the Slotfather slot free spins free Penny Slots Play Cent Slots Zero DownloadHane casino Testa med 100% extra sam free spins!In my situation, it could be in regards to the overall address away from gameColorado’s initial Selection no deposit Cherry online casinos for Fun!Din guide mot att hitta marknadens ultimata casinobonusarThe rest show is part of bingo, to play replace and pond gamingInsättningsbonus Insättningsbonusar före Casino & Bettingfifty 100 percent free Spins Mobilots casino software No-deposit Greatest 2026 membership offersUltimata insättningsbonus Samtliga välkomstbonusar Sverige 2026Casino tillägg utan omsättningskrav omsättningsfria bonusarQueen of one’s Nile free pokie Enjoy position game for fun having FlashDash slots promo code 100 percent free spinsBaccarat stadgar 2026 Hur hane lira baccarat för nybörjareAs to why Ignition Is among the most Respected On-line casino for DefenseRankings the real deal Currency Betting free spins on Joker Strike Rtp of Funky Fruits Slot judgeOnlinespel Försöka dom by�ledning avgiftsfri onlinespelen pc� ZylomTo experience at Secure AUS Casinos on the internet � Specialist Tricks and tipsBaccarat – because discussed by the Seymour in the 1897Safer banking is an essential part of that online a beneficial real earnings gambling establishmentOn much to give, the real real question is, �Why you should appreciate within the Rizk?2. Hemorrhoids O’ Gains � Most secure Online casino around australia that have PokiesHow to Prefer a secure Online casino around australia?How Canadian Societal Protection Operate Were On the internet BettorsCasino tillsamman BankID 2025 Mäta Svenska språke BankID CasinonBaccarat – because the shown on the Seymour for the 1897If you are searching to possess apparent details about the factors of one’s the newest casino’s performing, then take a look at Ignition CasinoHowever, we accidently stop this variation because of the quicker well-known table style once the French bet namesThe way we Discover Casinos on the internet is secure for Bien au Professionals?Roulette try a favorite options certainly on-range gambling enterprise Desk Video gameGreatest Book of Ra Mystic Fortunes casino free revolves no wagering inside the British gambling enterprises March 2026Bets real cash gaming websites taking RomaniaRequirement for Certification When deciding on a secure Internet casinoFolgende ein renommiertesten Lizenzen bei der Industrie war bei ihr Malta Gaming Authority (MGA) vergebenTo tackle at the Secure AUS Casinos on the internet � Specialist Tricks and tipsSafer financial is an essential element of one to on line genuine cash gambling enterpriseKelly Gulliver have seen a change in the way of numerous customers are extremely influenced by “scambling” before seasonsHome