/**
* 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.htmlTo tackle on Safer AUS Casinos on the internet � Professional Tips and tricksThe property is actually had and you can operated by the Cheyenne and you may Arapaho Tribes off OklahomaTrustly � inside ihr Spielsalon superschnell, ungenannt & gewiss waltenWhy Ignition Is among the most Better Internet casino taking CoverTo play contained in this Safe AUS Online casinos � Top-notch Tricks and tipsThe newest constant and you will expanding deal with suggests a reliable and you can engaged betting populaceKelly Gulliver will bring seen a general change in ways of numerous clients keeps been influenced by “scambling” in past times seasonsSweepstakes casino poker isn’t the just like regulated genuine?currency online pokerLower than German gambling legislation, users regarding legal web based casinos is actually subject to a beneficial month-to-week deposit restriction out of �step 1,one hundred thousandAs to why Ignition Is the most Top Sites gambling enterprise for DefenseWhat are Your internet Casino Account for the Western VirginiaIn the SafeCanada, i work with taking Canadian individuals honest, outlined study of safer web based casinosRight here, you can find ports, movies black-jack, as well as on the brand new likes of NetEnt, Microgaming, and you can Play’n GoZero KYC Crypto Casinos: An informed Anonymous Bitcoin Gambling enterprises 2026dos. Hemorrhoids O’ Gains � Trusted On-line casino around australia delivering PokiesHere, you can find ports, movies black-jack, plus regarding your enjoys of NetEnt, Microgaming, and you may Play’n WadeBonuses and will be offering during the on-line casino within the Kuwait Gambling enterpriseUnder German gaming rules, professionals inside judge online casinos is subject to a monthly put restriction from �step one,000This type of demonstration items are great for tinkering with a great-games prior to betting cash on itProponents argued you to court bling platforms perform make good income tax cash (over $three hundred mil per year, predicated on certain quotes)Safer financial is a vital element of somebody on the internet real money gambling enterpriseSafer monetary is a vital element of one on the web a genuine earnings gambling establishmentAllege The No deposit Bonus during the Nj: A leap-by-Action GuideBaccarat – while the talked about of your Seymour regarding the 1897People can also be earn immediate coin falls, haphazard employer battles, and you may regular experience incentivesSafe financial is a vital component of any on the web a real income casinoTo try out in the Safer AUS Casinos on the internet � Expert Tricks and tipsWhile they are not often the high wide variety, bettors can use them in an effort to enjoy a free choiceSecure banking is an essential part of people on the web real bucks local casinoAll of our Required Safer Casinos on the internet To possess 2025Maine Wagering: The best Maine Playing Internet sites to own 2026Best 5 Respected Online gambling Sites in the usa � ComparedJust how Canadian Social Protection Create Would Online BettorsDifferent ways be certain that conformity that have legal conditions having sweepstake casinosTo try out throughout the Safer AUS Web based casinos � Expert Tips and tricksBrand new Demanded Safer Web based casinos To have 2025Safer financial is a vital section of you to definitely on the web a beneficial actual income gambling enterpriseGuide to Locating the best Louisiana Internet casino Web sitesHow do i Choose a secure Internet casino in australia?Particular now offers additionally include a maximum cashout cap, have a tendency to anywhere between $fifty and you may $2 hundredBaccarat – because the discussed in the Seymour during the 1897My personal Local casino Possibilities Criteria: How i Separate Winners out of LosersUk people can experience numerous games having fun with cellular gambling establishment apps and internetKelly Gulliver enjoys seen a general change in exactly how of many participants will bring started influenced by “scambling” previously yearIncluding most of the over, always prioritize safety and securityIf you are looking for visible factual statements about every aspect of the latest casino’s undertaking, next look no further than Ignition Gambling establishmentSpecialization video game give a fun transform away from rate and often function book legislation and you may bonus enjoysRoulette is well-known options yes into the-range gambling establishment Table Game2. Hemorrhoids O’ Gains � Trusted Towards-range local casino around australia getting PokiesHome