/**
* 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.htmlHomedos. Luckland � Very Nice Extra Has the benefit of of all of the British Gambling InternetI don’t provide far lbs on the allow an on-line gambling establishment keepsAn upswing regarding Brief-Payout Casinos on the internet: Examining the Growing CreativityIt is an undeniable fact that most recent casino always exists winning, since the really-identified saying goesGames software from the Spree Spree Gambling establishment Alive Online game Spree Gambling enterprise Offersyou to definitely. High quality and value off Welcome OffersDelaware turned a good trailblazer in america online gambling landscape on the legalising items in to the industry into the 2012European union Vintage Multihand is actually an internet black-jack online game mirroring new guidance included in Eu casinosCannot Overlook This type of Amazing Cash from the Best Online casino SitesLower than German gambling law, members contained in this legal casinos on the internet was susceptible to 1 month-to-week place limitation of �one to,100000Exactly how we Rated the most popular Uk Betting WebsitesBovada – Best for On the internet Alive Specialist Roulette Video gameBy the exploring the fine print, we discover and therefore 100 % totally free spins keep genuine valueVideo game #you to definitely – Bovada – Dragon Roulette (RTP %)Play the top online slots regarding the market within SpaceCasinoAll of the more items just matter in the event the website also offers new online game we wish to enjoyDelaware became a great trailblazer in america gambling on line landscape of the legalising some thing inside field to the 2012You States in which Only On the web Sports betting try Legal (and not on-line casino)The rise from Temporary-Commission Casinos on the internet: Examining the Expanding DevelopmentWhich type of Gambling establishment Incentive is usually the Best?Select your preferred gambling establishment give and also you can be click the link with the casino webpages to sign-up and you can allege the bonusHow Must i Make use of this in the Real-world?Finest Casino games to play Along with your IncentiveMost editors try disappointed of the its feel overallHow Canadian Public Safety Efforts Cover Online GamblersDifference between Falls & Gains and you may Ports CompetitionsTo relax and play from the Safer AUS Casinos on the internet � Specialist Tricks and tipsWhat to look out for and when betting on the webRegistration Procedure of the real Currency Local casino Internet sitesWhat’s the Top Video game to try out from the an on-line Local casino?After you gamble if you don’t activities selection, you�re with your difficult-gained moneyDiscussing Enjoyable Vouchers to have United kingdom Pages in the Reveryplay Toward-range gambling establishmentHave fun with the most useful online slots games towards industry from the SpaceCasinoAngelique Visser is a keen iGaming experienced along with five years from writing sense to possess gambling establishment and you will sports betting internet sitesWhat is in charge playing and why could it be extremely important?Web based casinos provide a convenient and cozy feel because a player can play of his own residentialFind a very good slot competitions inside United kingdom web based casinosnot, be sure to remember the main benefit terms and you can one problems that impact the property value this new incentivesTop Online casino games to tackle With your BonusEvaluations of one’s Greatest 5 Websites for the Greatest Internet casino IncentivesLegality & Safeguards away from Real money Roulette around australiaThis new the VIP experience another important mark, delivering instantaneous rakeback, level-upwards incentives, tier-upwards bonuses, and you will planned incentivesEven the finest invited extra wouldn’t make up for an excellent subpar online gambling feelContinuing the mining individuals types regarding roulette, it is the right time to render Eu roulette the dueAn instant Publication on precisely how to Use line RouletteZero gambling criteria with the 100 percent free twist payoutsOf numerous professionals will appear due to their most useful local casino bonuses end up being very easy to allegePut and you may twist as a consequence of ?ten is actually entered into Super Prize ServerBaccarat – while the revealed because of the Seymour in to the 1897