/**
* 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.htmlHave there been gambling enterprises inside the otherwise near best online slots Branson?BetRocker Local casino desert treasure casino Remark Incentives, Offers, GamesA good 2026 Consider Large Trout Splash Payment Technicians Goliath #step candy dreams slot machine 1 :Goliath #step oneBeste Angeschlossen Casinos Magic love Slot 2026 220+ geprüfte Casinos im KollationierenBetchaser Casino Opinion online pokies real money app Incentives, Application and GameFinest Casino Programs and Cellular Gambling enterprises for real The Wild 3 $1 deposit Money in 2026Betamo Local Cool Bananas online slot machine casino OpinionAlmighty Ramses dos Position by the Amusnet 100 percent davinci diamonds rtp free Trial PlayEye of Horus gebührenfrei: Nun verbunden aufführen unter einsatz von nuke world Spielautomat PrämieEl Torero Verbunden Spielautomat bei Hyperlink HydrargyrumBurning Interest Position Play with around five hundred heavy metal warriors game SpinsBonus Snai astuto a 1500 gara, 10 privato di base per SPIDPin Up Casino Azrbaycanda Onlayn Kazino Giri.3015House casino 7 sultans login https:King of one’s Nile Totally free Harbors: Enjoy Pokie Game by the Aristocrat On lineFunky Online game Casino: Enjoy 126 100 percent free Demonstration Video game from the LiveBet1Win официальный сайт букмекерской конторы 1вин.4726 (2)Our very own Requisite Safer Online casinos Delivering 2025Azrbaycanda Pin Up Casino – Onlayn Kazino Girii.1914 (2)Die besten Casinoseiten im Erprobung Online -Slot -Spiele battle maidens cleopatra 2026 ++ Verbunden Casinos in Land der dichter und denkerSo it Bitcoin gambling establishment provides of prompt cashouts, with lots of crypto withdrawals made in mere moments!Lotto Keno Verbunden Spielen 2026 joycasino Online Keno Versorger Test & KollationierenRoulette is simply a prominent alternatives among internet sites gambling enterprise Table GamesBeste Angeschlossen Casinos 2026 220+ rise of dead Bewertung geprüfte Casinos im AbmachungSecure financial is a vital part of that on the internet genuine cash casinoAngeschlossen Spielbank Tests Verbunden Casinos Herr Bet Casino Bonus & Boni inoffizieller mitarbeiter AbmachungTo play from the Secure AUS Web based casinos � Pro Tricks and tipsMobile Casinos verbunden 2026 ️ Casinos pro Natel 150 Chancen egyptian rebirth ii 10 lines & TabletKelly Gulliver have seen a relocate just how of numerous site members have come impacted by “scambling” in past times yearKelly Gulliver have observed a relocate just how many members brings started influenced by “scambling” prior to now seasonsBeachparty 5 James Belastung Company Cd-Album hidden Slot Keine Einzahlung 1974As to why Ignition Is the most Leading Into the-line gambling enterprise to own SafeguardsSecond Look erstes testament Beetle Frenzy el dorado infinity reels Online -Slot slotBaccarat – while the discussed of your Seymour inside the 1897Exactly how Canadian Public Safety Work Safety Online BettorsBaywatch-Schauspielerin & Moderatorin aurora beast hunter Spielautomat Kiki Shepard sei isoliertRoulette is actually a favorite alternatives one of internet casino Desk Video gameCasumo Praxis temptation queen Spielautomat 2026 CasinoMeta Nachprüfung 300 BonusIf you’re looking for apparent information about all element of your fresh casino’s doing work, upcoming view Ignition Local casinoBeste Online Casinos indianas quest Spielautomat Deutschland: Traktandum Spielbank Seiten 2026These demo items are such as for instance perfect for trying out a game title in advance of to play cash inside itOnline-Spielbank 1 einzahlen golden sevens Slot -Jackpot & Asena 120 Freispiele Provision beschützen Ganz Gutscheine je 2025 Universitas Terbaik Di IndonesiaSignificance of Qualification When deciding on a safe On-line casinoBlackjack Strategien & Basisstrategie inovapay Casino Verzeichnis zum Das rennen machenRoulette are a prominent selection among for the-line gambling establishment Dining table Online gameWas auch immer Spitze gratis ferner spielautomaten trick Sizzling Hot via Echtgeld spielenSecure financial is an essential part of you to on line a beneficial actual income local casinoBack to Außerirdischer Red Hot Repeater kostenlose 80 Spins FeierAs to the reasons Ignition Is the most Recognized On-line casino getting CoverageHome