PluginProbe ʕ •ᴥ•ʔ
Download Manager / trunk
Download Manager vtrunk
3.3.62 3.3.61 3.3.60 3.3.59 3.3.58 3.3.57 3.3.56 trunk 2.1.3 2.3.0 2.5.96 2.5.97 2.6.2 2.6.96 2.8.3 2.9.99 3.0.4 3.1.05 3.1.07 3.1.08 3.1.11 3.1.12 3.1.14 3.1.17 3.1.18 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.2.04 3.2.13 3.2.14 3.2.16 3.2.18 3.2.19 3.2.21 3.2.22 3.2.23 3.2.24 3.2.25 3.2.27 3.2.28 3.2.29 3.2.30 3.2.31 3.2.32 3.2.33 3.2.34 3.2.35 3.2.37 3.2.38 3.2.39 3.2.40 3.2.41 3.2.42 3.2.43 3.2.44 3.2.45 3.2.46 3.2.47 3.2.48 3.2.49 3.2.50 3.2.51 3.2.52 3.2.53 3.2.54 3.2.55 3.2.56 3.2.57 3.2.58 3.2.59 3.2.60 3.2.61 3.2.63 3.2.64 3.2.65 3.2.66 3.2.67 3.2.68 3.2.69 3.2.70 3.2.71 3.2.72 3.2.73 3.2.74 3.2.75 3.2.76 3.2.77 3.2.78 3.2.79 3.2.80 3.2.81 3.2.82 3.2.83 3.2.84 3.2.85 3.2.86 3.2.87 3.2.88 3.2.89 3.2.90 3.2.91 3.2.92 3.2.93 3.2.94 3.2.95 3.2.96 3.2.97 3.2.98 3.2.99 3.3.00 3.3.01 3.3.02 3.3.03 3.3.04 3.3.05 3.3.06 3.3.07 3.3.08 3.3.09 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 3.3.16 3.3.17 3.3.18 3.3.19 3.3.20 3.3.21 3.3.22 3.3.23 3.3.24 3.3.25 3.3.26 3.3.27 3.3.28 3.3.29 3.3.30 3.3.31 3.3.32 3.3.33 3.3.34 3.3.35 3.3.36 3.3.37 3.3.38 3.3.39 3.3.40 3.3.41 3.3.42 3.3.43 3.3.44 3.3.45 3.3.46 3.3.47 3.3.48 3.3.49 3.3.50 3.3.51 3.3.52 3.3.53 3.3.54 3.3.55
download-manager / src / User / EditProfile.php
download-manager / src / User Last commit date
views 4 days ago Dashboard.php 5 months ago EditProfile.php 6 months ago Login.php 5 months ago PublicProfile.php 6 months ago Register.php 6 months ago User.php 2 months ago UserController.php 4 months ago
EditProfile.php
114 lines
1 <?php
2
3 namespace WPDM\User;
4
5 use WPDM\__\__;
6 use WPDM\__\Crypt;
7 use WPDM\__\Email;
8 use WPDM\__\__MailUI;
9 use WPDM\__\Session;
10 use WPDM\__\Template;
11 use WPDM\Form\Form;
12
13 if(!defined("ABSPATH")) die("Shit happens!");
14
15 class EditProfile
16 {
17 private static $instance;
18
19 public static function getInstance()
20 {
21 if (self::$instance === null) {
22 self::$instance = new self;
23 }
24 return self::$instance;
25 }
26
27 private function __construct()
28 {
29 add_action("init", [$this, 'logout']);
30 add_action('init', [$this, 'updateProfile']);
31 add_shortcode("wpdm_edit_profile", [$this, 'editProfile']);
32 }
33
34 function editProfile()
35 {
36 ob_start();
37 include Template::locate("dashboard/edit-profile.php", __DIR__ . '/views');
38 return ob_get_clean();
39 }
40
41 function logout()
42 {
43 if (isset($_REQUEST['logout']) && wp_verify_nonce(wpdm_query_var('logout'), NONCE_KEY)) {
44 wp_logout();
45 wp_safe_redirect(wpdm_login_url());
46 die();
47 }
48 }
49
50 function updateProfile()
51 {
52 $current_user = wp_get_current_user();
53 if (isset($_POST['wpdm_profile']) && is_user_logged_in() && wp_verify_nonce(wpdm_query_var('__wpdm_epnonce'), NONCE_KEY)) {
54
55 $error = 0;
56
57 $pfile_data['display_name'] = wpdm_sanitize_var($_POST['wpdm_profile']['display_name']);
58 $pfile_data['user_email'] = sanitize_email($_POST['wpdm_profile']['user_email']);
59
60
61 if ($_POST['password'] !== $_POST['cpassword']) {
62 Session::set('member_error', 'Password not matched');
63 $error = 1;
64 }
65 if (!$error) {
66 $pfile_data['ID'] = $current_user->ID;
67 if ($_POST['password'] != '')
68 $pfile_data['user_pass'] = $_POST['password'];
69
70 wp_update_user($pfile_data);
71
72 update_user_meta($current_user->ID, '__wpdm_title', __::query_var('wpdm_profile/title', 'txt'));
73 update_user_meta($current_user->ID, 'description', __::query_var('wpdm_profile/description', 'txt'));
74
75 if(isset($_POST['payment_account']))
76 update_user_meta($current_user->ID, 'payment_account', $_POST['payment_account']);
77
78 Session::set('member_success', 'Profile data updated successfully.');
79 }
80
81 if(__::query_var('__wpdm_profile_pic')) {
82 $profile = maybe_unserialize(get_user_meta(get_current_user_id(), '__wpdm_public_profile', true));
83 if(!is_array($profile)) $profile = [];
84 $profile['logo'] = __::query_var('__wpdm_profile_pic', 'url');
85 update_user_meta(get_current_user_id(), '__wpdm_public_profile', $profile);
86 }
87
88 do_action("wpdm_update_profile", $current_user->ID);
89
90 if (wpdm_is_ajax()) {
91 if (ob_get_length() > 0) @ob_clean();
92 if ($error == 1) {
93 $msg['type'] = 'danger';
94 $msg['title'] = 'ERROR!';
95 $msg['msg'] = Session::get('member_error');
96 Session::clear('member_error');
97 wp_send_json($msg);
98 die();
99 } else {
100 $msg['type'] = 'success';
101 $msg['title'] = 'DONE!';
102 $msg['msg'] = Session::get('member_success');
103 Session::clear('member_success');
104 $msg['data'] = $pfile_data;
105 wp_send_json($msg);
106 die();
107 }
108 }
109 header("location: " . $_SERVER['HTTP_REFERER']);
110 die();
111 }
112 }
113 }
114