/**
* 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.htmlHomeSo it Bitcoin gambling establishment brings regarding fast cashouts, with many crypto withdrawals introduced in mere minutes!As to the reasons Ignition Is the most Acknowledged On-line casino having CoverMostbet AZ – bukmeker ve kazino Mostbet Giri rsmi sayt.4289Kelly Gulliver will bring seen a move in the way of numerous clients have begun affected by “scambling” before 12 monthsIdeal 5 Trusted Gambling on line Web sites in the usa � OpposedAs to why Ignition Is one of Known Internet casino having CoverageDependence on Qualification When deciding on a secure On-line casinoInside SafeCanada, i manage providing Canadian benefits truthful, detailed studies out-of safer online casinosTo German gambling guidelines, profiles in this courtroom online casinos try subject to a month-to-month put limit of �step 1,000It Bitcoin gambling establishment brings with regards to quick cashouts, with plenty of crypto distributions brought in just times!Secure banking is an essential element of people on the internet a real income casinoThat it Bitcoin local casino brings with regards to prompt cashouts, with many crypto withdrawals brought in just times!Baccarat – given that informed me throughout the Seymour in the 1897The way we Pick Online casinos since Safe for Bien au Participants?Such trial designs have become perfect for experimenting with a game title prior to gambling cash into theLegal Landscaping to possess Online gambling in australiados. Heaps O’ Victories � Safest With the-range gambling establishment around australia bringing PokiesJust how Canadian Individual Cover Operate Safeguards On the internet GamblersKelly Gulliver has noticed a move in exactly how of numerous readers will bring getting influenced by “scambling” in past times 12 monthsThe Required Secure Casinos on the internet Delivering 2025If you are searching with visible information on every facet of this new new casino’s doing work, second look no further than Ignition CasinoKelly Gulliver will bring viewed a general change in the way of numerous subscribers attended influenced by “scambling” previously 12 monthsTo experience about Safe AUS Web based casinos � Professional Tips and tricksWithin this SafeCanada, i work on offering Canadian players honest, intricate data out-of safe online casinosDependence on Licensing Whenever choosing a secure On the-range casinoHow do i Eg a safe Towards the-line local casino around australia?This type of demo activities are great for trying out a good online game ahead of to relax and play actual cash involvedDoing German gambling legislation, users on legal web based casinos is largely subject to thirty days-to-month deposit limit regarding �step one,100Safe financial is an essential part of you to online a real income gambling establishmentThis type of demo designs are particularly just the thing for trying out a game prior to gaming actual cash in to theCourtroom Property which have Online gambling around australiaOur Demanded Safer Casinos on the internet Having 2025Legal Surroundings to have Gambling on line in australiaPin Up Casino Azrbaycanda Onlayn Kazino – Qeydiyyat v Giri.1995Here, you can find slots, videos black colored-jack, including on the wants out of NetEnt, Microgaming, and you will Play’n WadeRequirement for Degree When deciding on a secure Internet casinoImportance of Licensing When choosing a safe Online casinoBaccarat – since the demonstrated of the Seymour about 1897Kelly Gulliver provides observed a change in the manner many customers has started dependent on “scambling” previously seasonAs to the reasons Ignition Is among the most Trusted On-line casino to possess SafetyLess than Italian language betting rules, players in the court web based casinos is at the new mercy of good month-to-week set limit off �you to,one hundred thousandHow exactly we Discover Online casinos since the Safe for Au People?Exactly how Canadian Public Safeguards Perform Protect Online Bettors2. Piles O’ Gains � Safest On-line casino in australia to have PokiesSuch demo items are ideal for tinkering with an excellent-video game prior to playing cash in itExactly how Canadian Public Coverage Work Include Online GamblersHow do i Prefer a safe On-line casino in australia?The new Required Safer Casinos on the internet Delivering 2025How exactly to Choose a safe Internet casino in australia?