Addons.php
7 years ago
Admin.php
7 years ago
Ajax.php
7 years ago
Assets.php
7 years ago
Course.php
7 years ago
Gutenberg.php
7 years ago
Instructor.php
7 years ago
Instructors_List.php
7 years ago
Lesson.php
7 years ago
Options.php
7 years ago
Post_types.php
7 years ago
Q_and_A.php
7 years ago
Question.php
7 years ago
Question_Answers_List.php
7 years ago
Quiz.php
7 years ago
Quiz_Attempts_List.php
7 years ago
Rewrite_Rules.php
7 years ago
Shortcode.php
7 years ago
Student.php
7 years ago
Students_List.php
7 years ago
Template.php
7 years ago
Theme_Compatibility.php
7 years ago
Tools.php
7 years ago
Tutor.php
7 years ago
TutorEDD.php
7 years ago
Tutor_Base.php
7 years ago
Tutor_List_Table.php
7 years ago
User.php
7 years ago
Utils.php
7 years ago
Video_Stream.php
7 years ago
Withdraw.php
7 years ago
Withdraw_Requests_List.php
7 years ago
WooCommerce.php
7 years ago
User.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace TUTOR; |
| 4 | |
| 5 | |
| 6 | class User { |
| 7 | |
| 8 | public function __construct() { |
| 9 | add_action('edit_user_profile', array($this, 'edit_user_profile')); |
| 10 | add_action('show_user_profile', array($this, 'edit_user_profile'), 10, 1); |
| 11 | |
| 12 | add_action('profile_update', array($this, 'profile_update')); |
| 13 | add_action('set_user_role', array($this, 'set_user_role'), 10, 3); |
| 14 | } |
| 15 | |
| 16 | public function edit_user_profile($user){ |
| 17 | include tutor()->path.'views/metabox/user-profile-fields.php'; |
| 18 | } |
| 19 | |
| 20 | public function profile_update($user_id){ |
| 21 | $_tutor_profile_job_title = sanitize_text_field(tutor_utils()->avalue_dot('_tutor_profile_job_title', $_POST)); |
| 22 | $_tutor_profile_bio = wp_kses_post(tutor_utils()->avalue_dot('_tutor_profile_bio', $_POST)); |
| 23 | $_tutor_profile_photo = sanitize_text_field(tutor_utils()->avalue_dot('_tutor_profile_photo', $_POST)); |
| 24 | |
| 25 | update_user_meta($user_id, '_tutor_profile_job_title', $_tutor_profile_job_title); |
| 26 | update_user_meta($user_id, '_tutor_profile_bio', $_tutor_profile_bio); |
| 27 | update_user_meta($user_id, '_tutor_profile_photo', $_tutor_profile_photo); |
| 28 | } |
| 29 | |
| 30 | public function set_user_role($user_id, $role, $old_roles ){ |
| 31 | $instructor_role = tutor()->instructor_role; |
| 32 | |
| 33 | if (in_array($instructor_role, $old_roles)){ |
| 34 | tutor_utils()->remove_instructor_role($user_id); |
| 35 | } |
| 36 | |
| 37 | if ($role === $instructor_role){ |
| 38 | tutor_utils()->add_instructor_role($user_id); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | } |