/**
* 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.htmlHomeWere there casinos inside the or near Branson?Happy Charms Gambling establishment No deposit Incentive 2026Play 21,500+ Online Gambling games Zero InstallMethandienone Tabletten in Bodybuilding: Alles Wat Je Moet WetenObtaining twenty three or higher expensive diamonds in the heart normally personally fetch your a four hundredTo join up a free account which have Yellow Lion Local casino, just pursue a few easy stepsPenny bingo at Rainbow Wealth Local casino even offers a budget-amicable means to fix see bingoReal cash Gambling establishment Winners: Top Selections One to Match your PlaystyleThe internet black-jack industry houses many different variations of the video gameAlong with A seat To Good Televised WPT� Title ExperiencesResorts World Nyc comes with an enormous local casino and you can an excellent 400-space Hyatt Regency hotelReviewers overwhelmingly had an effective knowledge of the firmNottingham’s Alea is one of the 17 gambling enterprises to receive a great fourFor the Pop music position from Big time Gambling, look at the fairInside society, men and women are much more just starting to worthy of not simply benefits as well as protectionThe fresh new Vic has the benefit of an excellent valet services in below ground recreation areaWir hatten die schreiber diese neuesten Bonusaktionen beliebt ferner stellen Ihnen ebendiese momentan vorwegThe platform techniques purchases because of secure channels while keeping aggressive control minutes and you may restricted chargeReddish Lion Inn and you may Local casino 360 slot machines 8 desk gameStep 8: Leaving the game or Collecting The EarningsIn anderen wie Big Fishes Bonanza und Fire Stellvertretersymbol man sagt, sie seien lediglich 35 V. h. das Umsatze berucksichtigtWhether or not it suggestions had been released it can weaken one depend onActual champions continuously declaration similar designs no matter what award proportionsThis is the newest fun realm of gambling on line at the Richy Leo Local casino!Verzeichnis der Tagesordnungspunkt Gangbar Casinos unter einsatz von Paypal wanneer ZahlungsmethodeThat’s the difference in web browser lose and you will software excellence100 % free revolves into the Rainbow Wide range with no put requiredSpeak about the fresh new even offers from Red-colored Lion Gambling enterprise, in addition to invited bonuses, free spins, plusMention the newest offers out of Yellow Lion Gambling enterprise, as well as acceptance incentives, 100 % free revolves, plusThe brand new ongoing utilization of the new Gaming Operate Opinion light papers goes on so you’re able to shape aLive Spiele sehen seit ihrer Eroffnung diesseitigen ausreichen Verschutt gegangen zuruckgelegtRollXO Local casino introduced in recent times not as much as Dama LetterBeyond studies security, Yellow Lion Gambling enterprise are dedicated to producing in control betting meansTimely Payout Strategies within RioAce: Lender Transfer or any other OptionsVery reviewers was disappointed by the its sense overallThe primary variation is founded on the amount of pouches on the wheel plus the home edgeFinally, don’t forget to measure the app’s security featuresDown load ROYALEWIN On-line casino Mobile Application And you can Enjoy ImmediatelyDetachment that should take 1-24hours might have been five daysCent bingo from the Rainbow Money Gambling enterprise also offers a resources-amicable means to fix appreciate bingoFull Provides and you will Betting Alternatives Video game from the Yellow Lion Gambling enterpriseTalk about the latest also offers regarding Red-colored Lion Gambling enterprise, together with acceptance bonuses, 100 % free revolves, andMasquerade Harbors offers an elegant 20-payline knowledge of a maximum wager regarding $five-hundredTo join up a merchant account with Red Lion Gambling enterprise, merely follow a number of simple actionsThe fresh Rialto Gambling establishment was licensed and controlled by Uk Playing Payment lower than licence amount 57924How will you allege Purple Local casino added bonus and you can revolves?There is several of today’s very ines you realize and you may like – and then someCards costs such as Visa and you can Credit card would be the hottest universal possibilitiesThey operates below an effective Uk Gaming Fee licence (reference 39430)