/**
* 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.htmlHome32Red Gambling enterprise Remark 2026 Sample: Video game, Bonuses, Mobile AppThere are some large-top quality gambling establishment internet sites to pick from, for every single with different positives and negativesParticular names give no-deposit free revolves although some provide them with aside because the dollarsWR 10x 100 % free spin profits number (merely Harbors amount) inside 1 monthWagering standards establish how frequently you must play through the bonus amount before detachmentZodiac Local casino 1 Bonus Review Zodiac Casino 80 Free Revolves Dolphins Pearl Free $1 deposit for С1 Sign up Incentivestep one Deposit Casino NZ, deposit 10 get 100 casino Better step one Money Put Gambling enterprises 2026WATERMELON Drop Gamble On line free of bonus cash Lapalingo casino charge!Long Money Game slot free spins Branch Saloon FandomGreatest Paysafecard Casinos Guns N Roses slot United kingdom On-line casino PaysafecardGamble Free Position Games play Microgaming real money Zero Download, Simply Fun!How to Include Money to Big Bad Wolf Demo slot free spins Cash Application Cards in stores: Easy GuideGladiator Position Comment Among slots online real money the Epic Ports in the united kingdomImmortal Relationship Slot Totally free Play 22bet free spins no deposit Demo by CasinoMentorOnline Madison Peacock slot free spins Kitty Sparkle 1 deposit casinos Getting ChargeBedurfen Welche angewandten Bonuscode pro Spielbank Freispiele blo? Einzahlung?Moglich Spielbank frei Vermittlungsgebuhr: Ganz Tagesordnungspunkt Casinos ohne MaklercourtageBe sure to check the �conditions and terms� to be familiar with the full time limitErmi�glichen sich einen maximalen Erfolg aufgebraucht einen Complimentary Spins?Beste free Spins i Norge 2026 Hent tusenvis fra SpinBetter casino bonus uten innskudd free spins100 autonom iWinFortune kontakt i Norge flettverk betydningsløs bidrag admiral nelson fire and ice spilleautomat Våre 10 beste gratis online spilleautomaterGuide complet du casino en ligne : tout ce que vous devez savoir en 2024Guide complet du casino en ligne : tout ce que vous devez savoir en 2024Were there casinos inside the or near Branson?Happy Charms Gambling establishment No deposit Incentive 2026Play 21,500+ Online Gambling games Zero InstallMethandienone Tabletten in Bodybuilding: Alles Wat Je Moet WetenObtaining twenty three or higher expensive diamonds in the heart normally personally fetch your a four hundredTo join up a free account which have Yellow Lion Local casino, just pursue a few easy stepsPenny bingo at Rainbow Wealth Local casino even offers a budget-amicable means to fix see bingoReal cash Gambling establishment Winners: Top Selections One to Match your PlaystyleThe internet black-jack industry houses many different variations of the video gameAlong with A seat To Good Televised WPT� Title ExperiencesResorts World Nyc comes with an enormous local casino and you can an excellent 400-space Hyatt Regency hotelReviewers overwhelmingly had an effective knowledge of the firmNottingham’s Alea is one of the 17 gambling enterprises to receive a great fourFor the Pop music position from Big time Gambling, look at the fairInside society, men and women are much more just starting to worthy of not simply benefits as well as protectionThe fresh new Vic has the benefit of an excellent valet services in below ground recreation areaWir hatten die schreiber diese neuesten Bonusaktionen beliebt ferner stellen Ihnen ebendiese momentan vorwegThe platform techniques purchases because of secure channels while keeping aggressive control minutes and you may restricted chargeReddish Lion Inn and you may Local casino 360 slot machines 8 desk gameStep 8: Leaving the game or Collecting The EarningsIn anderen wie Big Fishes Bonanza und Fire Stellvertretersymbol man sagt, sie seien lediglich 35 V. h. das Umsatze berucksichtigtWhether or not it suggestions had been released it can weaken one depend onActual champions continuously declaration similar designs no matter what award proportionsThis is the newest fun realm of gambling on line at the Richy Leo Local casino!Verzeichnis der Tagesordnungspunkt Gangbar Casinos unter einsatz von Paypal wanneer ZahlungsmethodeThat’s the difference in web browser lose and you will software excellence