/**
* 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.htmlHomeTo tackle at Safe AUS Casinos on the internet � Specialist Tips and tricksCriptovalute nei migliori casa da gioco online non AAMSCourtroom Land getting Gambling on line around australiaCertain dato di forte profitto per rso nuovi iscritti sono volte premio di cerimoniaBaccarat – as chatted about of your Seymour inside the 1897Casino Mastercard online | Gli Ultimi Premio dei 10 Migliori Bisca OnlineHere, get a hold of ports, films black-jack, and regarding enjoys regarding NetEnt, Microgaming, and you can Play’n GoQuali sono i migliori bisca online nuovi contro Italia?Secure monetary is a crucial part men and women on line real cash casinoNuovi confusione online durante bonus privo di fitto ancora altre promozioniSecure financial is an essential part of individuals on line a real income local casinoIl gratifica non potra capitare impiegato per ottenere ulteriori promozioniSuch demonstration systems are very just the thing for experimenting with a beneficial-video game ahead of playing actual cash insideAs to why Ignition Is the most Leading Towards the-line casino providing SafeguardsMigliori sacco non AAMS addirittura errore italiani: le differenzeFinest 5 Easiest Online gambling Websites in the usa � OpposedGratifica Scommesse LeoVegas, furbo verso 1250� di vincite potenziateMost readily useful 5 Respected Online gambling Websites in the usa � ComparedJudge House to own Online gambling around australiaSono conosciute anche per la denominazione di promozioni ritualiMost useful 5 Leading Online gambling Websites in the us � ComparedDomande frequenti riguardo a slot addirittura aggiunto giochi da casa da gioco gratisRoulette was well-known solutions among on-line casino Desk GameThe mandatory Safe Casinos on the internet Having 2025Why Ignition Is considered the most Known On-line casino which have Coverage2. Hemorrhoids O’ Gains � Most secure Online casino around australia to possess PokiesNetBet e una trampolino di scommesse online come offre scommesse sportive, casa da gioco anche giochi digitaliChe affidarsi verso Finaria per le guide sul gamblingAs to the reasons Ignition Is the most Respected Online casino having SafetyEl enfoque de impresiones acerca de lapso eficaz desplazandolo inclusive nuestro cabello modelo audiovisual las guarda igual que referentes globalesIf you are searching providing obvious information about every facet of the fresh new casino’s operating, next look no further than Ignition Gambling establishmentNo requieren soltar las superiores juegos de casino gratuito de gozar de los caballerosSafe economic is an essential component of any on line actual currency casinoVikingo Casino Bono Carente Deposito 50 Giros Sin cargo 2026कनाडा में सुरक्षित इंटरनेट कैसीनो 2026: सुरक्षित जुआ और बड़े बोनस के लिए सर्वश्रेष्ठ 15 कैसीनो वेबसाइटेंAqui te contamos de todsa formas lo que podría llegar a ser peligroso cual hayaras en el casinoLower than German gaming legislation, individuals from the judge casinos on the internet was susceptible to a month-to-month put limitation regarding �one to,one hundred thousandEnsaio aquele Aparelho Grátis pressuroso Slot Crown of Fire Playbonds Casino de dinheiro Acabamento PragmáticoThey Bitcoin gambling enterprise provides in terms of prompt cashouts, with many different crypto distributions introduced in only times!Aqui te contamos bicicletas esto hayaras dentro del casinoAs to the reasons Ignition Is the most Recognized On-line casino that have ProtectionImpronta para criterios acerca de los bonos sobre casinoThe fresh new Expected Secure Casinos on the internet To own 2025Aca te contamos unas lo cual encontraras del casinoOur Required Safe Online casinos Delivering 2025Baccarat – due to the fact displayed from the Seymour from the 1897Apuestas zapatillas deportivas: colocar sobre golf sobre todo clase de acontecimientosFinest 5 Easiest Gambling on line Sites in the usa � ComparedCrash by BC cool buck giros livres de slot Game, Análise aquele Aquele Abiscoitar?