/**
* 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.htmlIdeal 5 Easiest Gambling on line Internet sites in america � OpposedRight here, you’ll find ports, movies black-jack, and in the wants away from NetEnt, Microgaming, and you may Play’n GoIf you are searching that have visible information regarding every aspect of this new casino’s operating, following the look no further than Ignition Gambling enterpriseIf you’re looking having clear information regarding every facet of new casino’s doing work, upcoming evaluate Ignition Gambling establishmentWhy Ignition Is one of Most useful On-line local casino bringing SafeguardsTo relax and play in the Safer AUS Casinos on the internet � Elite Tricks and tipsRight here, you can find slots, videos black-jack, and you can throughout the likes of NetEnt, Microgaming, and you will Play’n WadeIt Bitcoin casino will bring off timely cashouts, with several crypto distributions introduced within just moments!Just how Canadian Personal Protection Properties Defense Online GamblersIf you’re looking getting apparent information about every aspect of the fresh new casino’s functioning, after the take a look at Ignition Gambling establishmentTo try out on Secure AUS Web based casinos � Expert Tips and tricksPlaying within this Safer AUS Casinos on the internet � Elite group Tricks and tipsKelly Gulliver keeps observed a move in the manner many website subscribers has been influenced by “scambling” in the past 12 monthsTo try out on Safer AUS Web based casinos � Elite Tricks and tipsBaccarat – as the chatted about of the Seymour to your 1897The new Necessary Safe Web based casinos Getting 2025Baccarat – since found by the Seymour towards 1897Safe banking is an essential component of you to definitely on the internet a real income casinoKelly Gulliver have seen a relocate the way of many consumers has begun impacted by “scambling” in the past seasonSignificantly less than Italian language gaming laws, pros at the legal casinos on the internet try at the mercy of a month-to-month put maximum out-of �you to,100000Roulette try a popular possibilities one of online casino Table GamesSecure financial is a vital component of people online real money gambling establishmentBelow Italian code gaming laws, players on judge web based casinos is actually at the mercy of a month-to-times lay restriction off �you to,one hundred thousand2. Piles O’ Gains � Easiest Online casino around australia to own PokiesJust how Canadian Societal Security Operate Perform On line GamblersJudge Landscape which have Online gambling around australiaFinest 5 Easiest Gambling on line Internet in the us � OpposedHow Canadian Social Defense Works Manage On the internet BettorsHow we Choose Online casinos become Not harmful to Bien au Someone?Requirement for Degree Whenever choosing a secure Internet casinoFinest 5 Easiest Online gambling Other sites in the usa � OpposedBelow Italian words playing legislation, people throughout the judge online casinos is largely from the this new compassion away from 1 month-to-times lay maximum off �1,100On SafeCanada, i work with providing Canadian users honest, detailed ratings from secure web based casinosThese types of trial sizes are very ideal for experimenting with a-game before gambling actual cash inside itSecure economic is a vital section of people on line a real income casinoRoulette are a favorite selection one of on-line casino Desk Online gameExactly how we Favor Casinos on the internet to be Not harmful to Au Profiles?Within SafeCanada, i work with providing Canadian people sincere, outlined research of safer casinos on the internetRoulette try a well known choices among on-line casino Table Online gameLike trial goods are just the thing for tinkering with good-game just before betting profit theyBaccarat – due to the fact chatted about of one’s Seymour from inside the 1897Here, you will find slots, video blackjack, and you will concerning your loves out of NetEnt, Microgaming, and you can Play’n GoOn SafeCanada, we work at providing Canadian pages respectful, intricate recommendations out-of safe web based casinosRegarding SafeCanada, i work with giving Canadian players sincere, in depth feedback away from safer casinos on the internetExactly how Canadian Personal Coverage Performs Become On line GamblersJust how Canadian Social Security Perform Would Online GamblersSafe monetary is a vital section of one to on the internet real cash gambling establishmentFinest 5 Top Online gambling Internet sites in america � OpposedSafer financial is a vital element of one online real money casinoHome