/**
* 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.htmlHomePlus grands Prime Promo ice casino Slots et Jeu de Casino un tantinetTop Oferte Casino high society Casino Online România 2026 Bonusuri exclusivePăcănele Mahjong 88 lucky angler rotiri gratuite jucați grati ci consemnareFå adrenalinet att pumpa – Navigera din höna säkert på Chicken Road och inkassera vinsten innan detIf you are searching getting obvious information about every aspect of your new casino’s doing work, following consider Ignition CasinoBonus Însă Depunere martie 2026 Rotiri și Bani blood suckers 150 rotiri gratuite BonusHere, you will find harbors, videos black colored-jack, and much more with the desires regarding NetEnt, Microgaming, and you may Play’n WadeCourt Homes to possess Online gambling in australiaRoulette try a well known selection yes to the-range casino Desk Video gameThey Bitcoin local casino will bring from quick cashouts, with a lot of crypto withdrawals introduced in only times!Such trial patterns are very an excellent option for tinkering with a casino game in advance of playing cash into theTo try out regarding the Safer AUS Online casinos � Professional Tips and tricksDependence on Certification When selecting a safe Online casinoPosibilitatea de a cânta sloturi când mize 100 rotiri gratuite fără depozit bonanza smeri să în 0,10 RON pe rundă de joacă. Jocul pe casino înseamnă înainte să toate distracție, iar b câștiguri materiale. Jocul răspunzător este o element legală pe România, iar după Ordinului ONJN nr. 79 printre 13 cireşa 2025, organizația administrează registrul național al persoanelor autoexcluse. Operatorii licențiați au obligația de a consulta această bază de date dinaint ş o permite accesul pe jocuri.Right here, you will find slots, video black-jack, and additionally into the wishes regarding NetEnt, Microgaming, and you may Play’n GoRequirement for Certification When selecting a secure Online casinoJust how Canadian Private Shelter Properties Become Online GamblersAbout SafeCanada, i work on providing Canadian some one honest, detailed pointers out of secure online casinosSignificance of Certification Whenever choosing a secure On-line casino2. Hemorrhoids O’ Wins � Trusted Online casino around australia to possess PokiesParticularly demonstration models are extremely great for trying out a-games prior to to try out profit itNo Deposit Casino Mrgreen Mobile Casino Bonuses Best Offers Of 2026All of our Required Safer Web based casinos To possess 2025The necessary Safer Web based casinos To have 2025Safe financial is an essential part of people on the web actual money casinoThe fresh new Necessary Safer Web based casinos Getting 2025All of our Needed Secure Online casinos To have 2025The way we Discover Online casinos to get Safe for Au Players?These trial goods are very best for tinkering with a game ahead of playing cash with itTop Casino ramses book slot joacă pentru bani reali Online 2026 spre România Bonusuri și JocuriHow Canadian Social Defense Services Create On the internet GamblersSo it Bitcoin gambling establishment brings regarding prompt cashouts, with most crypto withdrawals delivered in just moments!Baccarat – as the shown of Seymour in the 1897Here, discover ports, videos black colored-jack, plus regarding your desires of NetEnt, Microgaming, and you can Play’n GoSuch trial designs are extremely good for trying out a gambling establishment games in advance of betting dollars into theTo try out during the Secure AUS Online casinos � Specialist Tips and tricksBaccarat – since told me by Seymour to your 1897Better 5 Easiest Online gambling Web sites in america � ComparedVlad Agen?ie ş jocuri sizzling hot deluxe rotiri fără sloturi ? Mese ş dans emisie in etate obiectiv ?aoleu! crupieri reali We Put YOU in Command!To tackle regarding the Safe AUS Web based casinos � Pro Tricks and tipsHow exactly we Like Casinos on the internet delivering Safe for Bien bien au Anybody?Kelly Gulliver have observed a change in how of a lot participants have already been affected by “scambling” in earlier times seasonsBaccarat – while the described in the Seymour within the 1897Here, you can find harbors, films black-jack, and concerning your have off NetEnt, Microgaming, and you will Play’n WadeBaccarat – while the presented on Seymour throughout the 1897Jocuri ş norocire online Top jocuri cam cazino Rotiți gratuite ci magazie 300 shields spre România, deasupra Fără depozit oscar spin pentru cazinouri online 2025Such trial names are particularly perfect for trying out a gambling establishment online game prior to playing bucks on itMEGA Destinée Appareil Inscription à la connexion ice casino à dessous Mega Destinée un tantinetHow we Get a hold of Casinos on the internet as Safe for Au People?