PluginProbe
Tutor LMS – eLearning and online course solution / 1.3.5
Tutor LMS – eLearning and online course solution v1.3.5
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
tutor / classes / User.php

User.php in Tutor LMS – eLearning and online course solution 1.3.5, at classes/User.php

45 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TUTOR;
4
5 if ( ! defined( 'ABSPATH' ) )
6 exit;
7
8
9 class User {
10
11 public function __construct() {
12 add_action('edit_user_profile', array($this, 'edit_user_profile'));
13 add_action('show_user_profile', array($this, 'edit_user_profile'), 10, 1);
14
15 add_action('profile_update', array($this, 'profile_update'));
16 add_action('set_user_role', array($this, 'set_user_role'), 10, 3);
17 }
18
19 public function edit_user_profile($user){
20 include tutor()->path.'views/metabox/user-profile-fields.php';
21 }
22
23 public function profile_update($user_id){
24 $_tutor_profile_job_title = sanitize_text_field(tutor_utils()->avalue_dot('_tutor_profile_job_title', $_POST));
25 $_tutor_profile_bio = wp_kses_post(tutor_utils()->avalue_dot('_tutor_profile_bio', $_POST));
26 $_tutor_profile_photo = sanitize_text_field(tutor_utils()->avalue_dot('_tutor_profile_photo', $_POST));
27
28 update_user_meta($user_id, '_tutor_profile_job_title', $_tutor_profile_job_title);
29 update_user_meta($user_id, '_tutor_profile_bio', $_tutor_profile_bio);
30 update_user_meta($user_id, '_tutor_profile_photo', $_tutor_profile_photo);
31 }
32
33 public function set_user_role($user_id, $role, $old_roles ){
34 $instructor_role = tutor()->instructor_role;
35
36 if (in_array($instructor_role, $old_roles)){
37 tutor_utils()->remove_instructor_role($user_id);
38 }
39
40 if ($role === $instructor_role){
41 tutor_utils()->add_instructor_role($user_id);
42 }
43 }
44
45 }