/**
* 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.htmlHomeThe way we Pick Casinos on the internet isn’t bad for Bien au Users?Kelly Gulliver have observed a modification of ways of several subscribers features come impacted by “scambling” in past times 12 monthsSecure financial is an essential part of a single on line a genuine money gambling enterpriseWhich Bitcoin casino brings when it comes to punctual cashouts, with plenty of crypto distributions put within just minutes!Judge Landscaping which have Online gambling in australiados. Piles O’ Wins � Most secure Internet casino in australia with PokiesRoulette try common choice one of into the-line local casino Dining table GameBelow German playing laws, participants inside courtroom online casinos are at the mercy of a great month-to-few days lay restrict regarding �1,100000Secure banking is a vital component of one on line real cash casinoOn SafeCanada, i work on delivering Canadian gurus honest, intricate critiques from safer web based casinosAs to the reasons Ignition Is the most Leading Internet casino delivering SafetyIf you are searching having clear factual statements about every aspect of the fresh casino’s performing, adopting the check Ignition Gambling establishmentAround German betting regulations, people inside judge online casinos are susceptible to a month-to-few days place maximum of �1,100Court Surroundings getting Online gambling around australiaFinest 5 Safest Gambling on line Internet in the usa � ComparedThe way we Get a hold of Casinos on the internet taking Not harmful to Au Profiles?How Canadian Public Shelter Carry out Would On the web BettorsWithin this SafeCanada, i manage bringing Canadian gurus sincere, outlined critiques away from safer online casinosHow Canadian Personal Safety Create Security On the web BettorsAs to why Ignition Is one of Leading To the-range gambling enterprise getting DefenseIn the SafeCanada, i work with giving Canadian professionals polite, detail by detail ratings away from safe web based casinosIt Bitcoin gambling establishment provides with regards to brief cashouts, with a lot of crypto withdrawals setup just a few minutes!Around German playing rules, people on judge online casinos try subject to a month-to-month put maximum out-of �step one,100Need for Licensing When choosing a secure Online casinoRight here, you will find slots, movies black-jack, and additionally for the keeps of NetEnt, Microgaming, and you can Play’n GoBaccarat – because showed of the Seymour towards 1897Baccarat – once the talked about of your own Seymour from the 1897Most readily useful 5 Trusted Online gambling Sites in america � OpposedKelly Gulliver possess noticed a shift in the manner of many readers brings be impacted by “scambling” in past times 12 monthsImportance of Degree Whenever choosing a secure Online casinoExactly how Canadian Public Cover Really works Is On the internet BettorsExactly how we Choose Online casinos to be Not harmful to Au Members?How can i Favor a secure Internet casino in australia?Inside SafeCanada, i work on providing Canadian somebody truthful, detail by detail studies out of safer web based casinosKelly Gulliver features viewed a change in the way of a lot clients provides become impacted by “scambling” in past times yearKelly Gulliver have observed a general change in the way in which many people will bring already been dependent on “scambling” in earlier times seasonsDependence on Qualification When selecting a secure For the-range gambling establishmentWhy Ignition Is one of Acknowledged Online local casino taking DefenseWhy Ignition Is among the most Acknowledged Internet casino getting ProtectionSuch trial designs are an excellent option for trying out a game title title prior to gaming actual cash in itn Yax Azrbaycan Kazinolar 2026 Yeni Oyunular n Bonuslar.2351Lower than German gambling laws, people in the courtroom online casinos is actually subject to thirty day period-to-week put restriction regarding �step 1,100000How can i Including a safe Internet casino in australia?Kelly Gulliver provides observed a move in the manner of numerous website subscribers enjoys started determined by “scambling” before yearAs to the reasons Ignition Is one of Acknowledged On-line casino to own SafeguardsLegal Land having Online gambling in australiaVAVADA Вавада казино официальный сайт регистрация вход.3041And this Bitcoin gambling establishment provides from prompt cashouts, with a lot of crypto withdrawals produced in merely times!As to the reasons Ignition Is the most Most readily useful Internet casino to have Safeguards