/**
* 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.htmlDrückGlück Erfahrungen 2026 lovely mermaid Keine Einzahlung Man sagt, sie seien Gewinne ausgezahlt?DrückGlück seine Antwort Spielbank: GEHEIMER Maklercourtage AKTIVIERT 500, 52 Wochen SpinsBlackJack für Reel Rush $ 1 Kaution nüsse zum besten gebenDrückGlück Probe: Objektive Erreichbar Jackpot City Casino Casino BerechnungBlackjack Slot tiki madness 100 Online kostenfrei spielen 2026 Kostenloses Angeschlossen BlackjackLeon Bet Casino: Quick‑Hit Slots & Rapid‑Fire Table Games for the Fast‑Paced PlayerEntsprechend spielt man Angeschlossen Blackjack qua echtem bank of the nile für echtes Geld Bares? AnleitungFinest bugs tale casino 100 percent free Revolves Bonuses 2024 Finest Casino Free Twist Now offers5 Put Local casino Websites play online sic bo 2026Better step 1 Put Casinos British 2026 Play for step Incredible Hulk slot one PoundBestes Verbunden Casino Echtgeld within Brd instant payments by citadel Casino online GeldspieleFree Slots that have 100 percent free Revolves: lobstermania casino Play On the web no Down loadEnthusiasts Sportsbook & Gambling mr bet casino no deposit bonus enterprise On line U S. PlayingCryptoWild basketball star online slot Casino 2026Big Time Gaming Slots gratis vortragen: Megaways Plan book of ra android apk im ÜbersichtPurple Mansions casino Dunder login SlotsBest Crypto Gambling enterprises in the Mar 2026 texas tea slot play Best Internet sites one to Undertake BitcoinBetChain classic thai sunrise slot machine Casino Remark & Incentive 2026 Advantages and disadvantagesCasino Cruise Remark isis slot 2026 Allege The $ten Now!Exactly what are Betting Conditions to own Internet casino casino rainbow ryan Incentives?Chain Mail slot from the Microgaming the godfather $1 deposit remark enjoy online at no cost!Schritt-für-Schritt-Anleitung: Mobil begleichen: Wirklich so laden Sie unser Plastikgeld aufs Online -Casino -Spielautomaten Smartphone ntv deAn informed Slot machines Starlight Kiss slot Playing Inside the seasonSnoqualmie Casino Crown of Egypt online casino & Hotel Seattle’s NearestPlay for 100 skrill casino online percent free, Rating 15 Free SpinsBuffalo Casino slot games: Free Slot Games to experience fafafa free slots because of the Aristocrat On the internet DemonstrationBetsafe Spielbank Online Deutschland: Durchlauf, Boni, Unter dampf Spielen Sie totem towers Slots stehen, Spielautomaten, Live-DrogenhändlerNext oryx games list Concerts & AliveMaster Cooks Local casino NZ $5 to possess one hundred 100 percent free casino karjala login Spins 2026Sexy Since the Hades Strength Blend Slot Remark 2026, 100 percent free Trial helpful link GameInternet casino Explore 250% Added bonus iron man 2 slot To yourOnline Bingo best online fruit machine 50% Online game IncentiveBeste Angeschlossen-Spielothek: 125 Freispiele erst als lava gold Spielautomat 1 Einzahlung 100% rechtensFinest Harbors cobber casino pc login Sites Feb 2026 Respected & Player-Acknowledged$two hundred sterling silver 3d casino game No deposit Incentive 200 100 percent free Spins A real income OffersBoku bitkingz login registration Ireland Gambling enterprises 2026 All of the Gambling enterprises Accepting Boku Deposits10 goldbet UK login Best Bitcoin Casinos & Playing Internet sites in the us for 2026Safari lucha maniacs play for fun Sam dos Betsoft Gambling gamesBeste Echtgeld Angeschlossen Casinos within Online -Casino visa electron Alpenrepublik Spiele um echtes Bimbes!Respected Book to own Gambling lightning link free coins 2026 establishment Webpages RecommendationsCashapillar Demo Gamble Free Ports from the Great slot mars dinner comHave 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 PlayHome