/**
* 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.htmlArguments culturelles du prime sans nul i� annales de quelques � : ce qu’il faut savoirIt Bitcoin gambling establishment brings with regards to timely cashouts, with most crypto withdrawals lead-in only minutes!Lower than there’s the guide to get ideal casinos on the internet in almost any gambling marketsSuch trial designs have become great for trying out a casino game prior to betting bucks in itFor the SafeCanada, we focus on taking Canadian players respectful, outlined product reviews out-of safer online casinosTo play inside Secure AUS Casinos on the internet � Expert Tips and tricksThe first step is to try to get the �Indication Up’ otherwise �Register’ button on the casino’s web siteHow we See Casinos on the internet is not bad for Au Professionals?But avec Conserve Biographies : 200� Comble parmi Absencedos. Heaps O’ Victories � Easiest On-line casino in australia for PokiesRight here, you’ll find ports, video clips black-jack, plus regarding loves from NetEnt, Microgaming, and Play’n WadeJust how Canadian Individual Security Jobs Include Online BettorsCourt Land to own Gambling on line in australiaImportance of Licensing Whenever choosing a safe Internet casinoIt Bitcoin gambling enterprise brings with respect to prompt cashouts, with most crypto distributions manufactured in simply moments!Kelly Gulliver possess noticed a change in the way of a lot customers brings been determined by “scambling” prior to now seasonExactly how Canadian Social Coverage Properties Cover On line GamblersHere, you can find ports, video black-jack, plus into wants regarding NetEnt, Microgaming, and you can Play’n GoIt adds a layer of excitement that every casinos only you should never promoteNeed for Certification When choosing a safe Towards-range local casinoTips Favor a safe Internet casino around australia?Kelly Gulliver have seen a general change in ways of several readers attended determined by “scambling” prior to 12 monthsIf you’re looking for clear details about every aspect of the newest fresh new casino’s operating, then look no further than Ignition Local casinoGreatest 5 Trusted Online gambling Websites in the us � ComparedHow can i Like a safe To your-range local casino in australia?Most readily useful 5 Easiest Gambling on line Sites in the us � ComparedAs to the reasons Ignition Is the most Acknowledged On-line casino having SecurityOur Expected Secure Web based casinos Getting 2025The online harbors catalog is sold with a combination of antique online game, modern jackpots, and you will progressive movies slotsNeed for Certification Whenever choosing a safe On-line casinoGetting alive broker online game, the results is dependent upon the new casino’s regulations along with your history actionIt possess ports, desk game, and real time specialist online casino games with a high restriction betsBaccarat – because the demonstrated about Seymour when you look at the 1897MrQ have a huge profile certainly one of online casino users, with a stronger Trustpilot rating off fourSuch demo designs are particularly helpful for experimenting with a-game ahead of to tackle cash on itThe video game have spread pays and you will tumbling victories, having multipliers that may reach up to 500?Kelly Gulliver has actually noticed a relocate the way in which of many clients have started influenced by “scambling” prior to 12 monthsWe have ranked the web based casinos dependent on its video game and you can haveThe latest UKGC handles operators and you can requires steps to end currency laundering and you may underage gamblingAs to why Ignition Is one of Top On the web gambling establishment which have SafeguardsLicensed All of us systems render put constraints, choice limitations, go out reminders, short-term trips, and you can self-different softwareIdeal 5 Leading Online gambling Internet in the us � OpposedThe best online casino bonuses enable you to claim big rewardsRoulette was a favorite selection yes internet casino Table GamesThe latest technical storage or accessibility that is used simply for unknown analytical intentionsAndy champions posts that assists participants create secure, informed choice and you may retains casinos to help you highest standardsSecure banking is an essential section of anyone on line a real income gambling establishmentSafety regarding Funds You can expect a basic out of shelter of buyers funds stored aroundThe best aspect to consider whenever choosing a fees strategy are security and safetyHome