/** * 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 TV https://validator.w3.org/feed/docs/rss2.html Home Finest Ports Gambling establishment Review Professional & Pro Evaluations 2026 IGTからファラオズラックの無料トライアルをプレイしよう Top Online casinos on You S Pro Reviews April 2026 Finest Casino: Transcending Online casino Gaming Feel Google Enjoy Shop アプリを発見 Google Enjoy Let Online slots Top Totally free & Trial Games inside the 2026 How we Rated the big 50 Gambling establishment Slots in america Bonus Buy Ports Casino Tournament טי וי. פוינט המרכז לכורסאות טלויזיה Enjoy Slot Games Online Most useful Online slots スフィンクス 5 5 マイル Ideal Online casino Position Online game 2026 Gamble Preferred Ports Better Web based casinos for real Currency 2026 stu Darmowych Spinów z brakiem Depozytu przy nv casino kasynach przez internet ️ Najkorzystniejsze kasyna spośród setka free spinami w naszym kraju Plaisir Avec Salle jouer twin spin emplacements de jeu Plaisir Of Ra ファラオズ・チャンス スロットマシンゲーム:IGTによる完全無料のスロットゲームをオンラインでプレイ Directory of Sweepstakes Gambling enterprises: Most readily useful Sweeps Casinos to have April 2026 Wager On the web Position Games during the South Africa with YesPlay 天然貴金属ポジションレビュー 完全無料のデモ機能で楽しみながら、実際の収入を得られます Online slots games British Gamble 900+ Position Online game The real deal Money Top Online slots games & Real cash Position Casino Websites for the April 2026 Finest A real income Harbors to tackle when you look at the 2026 Select Finest Slots On the web アイアンマン2ポートレビュー Gamble on Top 10 Slots On the internet for real Currency Casinos 2026 Online casino Uk Play Casino games Online at the Red Casino Wager On line Slot Online game in the Southern Africa with YesPlay ダウンロード不要で29,126種類のスロットゲームを楽しもう! This new Members Rating $fifty 100percent free A real income Online slots games Best Real cash Slots On line 2026 Us Finest Picks Comment un post à élimination directe nous ne savais loin fabriquer de vrais avec Instagram ? Instagram Ideal No deposit Bonuses 2026 Most useful You Casinos on the internet On-line casino Gamble A real income Online casino games at GGBet 1win официальный сайт букмекерской конторы 1вин.9273 Find the best Slots to play On line for real Money On the web Harbors An informed You Position Internet & Real money Online slots to have 2026 Best Personal Gambling establishment Bonuses 2026 No deposit Necessary Free Sweeps Gold coins レストランカジノでは、入金不要の100%無料ウェルカムボーナスも提供しています。ニューヨーク・トゥデイのリアルマネー #step one Public Slots & Online casino games Casino Balade Gratuit : 5 goldbet pour les casinos en ligne sans dépôt Meilleurs Emploi de 2026 Silver Fish Harbors Gambling games Applications on google Gamble 100 percent free Ports: Enjoy 9,000+ Free online Slot Online game Zero Down load Online slots games Better Totally free & Demo Video game in 2026 Enjoy 560+ Free Position Online game On the internet, No Signal-Upwards or Obtain Darmowe Spiny w całej polskich kasynach 2025 Kody pod free nv casino spins Free Harbors On the internet Gamble 100 percent free Slot Video game On line Play 31,000+ Free Slots & Games No deposit No Down load Tiptop Bet: Quick‑Fire Slots en Fast‑Track Wins voor de Moderne Gokker Interest Needed! Cloudflare On line Slot machines having Bonus Series & Game