PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
← All changes | includes/class-meta.php +223 -318 1.0.171.2.74 View file →
@@ -8,108 +8,114 @@
8 8 * @author GeoDirectory Team <info@wpgeodirectory.com>
9 9 */
10 10 class UsersWP_Meta {
11 11
12 - /**
13 - * Gets UsersWP setting value using key.
14 - *
15 - * @since 1.0.0
16 - * @package userswp
17 - *
18 - * @param string $key Setting Key.
19 - * @param bool|string $default Default value.
20 - * @param bool $cache Use cache to retrieve the value?.
21 - *
22 - * @return string Setting Value.
23 - */
24 - public function get_option( $key = '', $default = false, $cache = true ) {
25 - if ($cache) {
26 - global $uwp_options;
27 - } else {
28 - $uwp_options = get_option( 'uwp_settings' );
29 - }
30 - $value = ! empty( $uwp_options[ $key ] ) ? $uwp_options[ $key ] : $default;
31 - $value = apply_filters( 'uwp_get_option', $value, $key, $default );
32 - return apply_filters( 'uwp_get_option_' . $key, $value, $key, $default );
33 - }
12 + /**
13 + * Gets UsersWP user meta value using key.
14 + *
15 + * @since 1.0.0
16 + * @package userswp
17 + *
18 + * @param int|bool $user_id User ID.
19 + * @param string $key User meta Key.
20 + * @param bool|string $default Default value.
21 + *
22 + * @return string User meta Value.
23 + */
24 + public function get_usermeta( $user_id = false, $key = '', $default = false ) {
25 + global $wpdb;
34 26
35 - /**
36 - * Updates UsersWP setting value using key.
37 - *
38 - * @since 1.0.0
39 - * @package userswp
40 - *
41 - * @param string|bool $key Setting Key.
42 - * @param string $value Setting Value.
43 - *
44 - * @return bool Update success or not?.
45 - */
46 - public function update_option( $key = false, $value = '') {
27 + if ( ! $user_id ) {
28 + return $default;
29 + }
47 30
48 - if (!$key ) {
49 - return false;
50 - }
31 + if ( ! $key ) {
32 + return $default;
33 + }
51 34
52 - $settings = get_option( 'uwp_settings', array());
35 + $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
53 36
54 - if( !is_array( $settings ) ) {
55 - $settings = array();
56 - }
37 + if ( uwp_str_ends_with( $key, '_privacy' ) ) {
38 + if ( uwp_str_ends_with( $key, '_tab_privacy' ) ) {
39 + $obj_key = $user_id.'_tabs_privacy';
40 + $row = wp_cache_get( $obj_key, 'uwp_usermeta_tabs_privacy' );
57 41
58 - $settings[ $key ] = $value;
42 + if ( ! $row ) {
43 + $row = $wpdb->get_row( $wpdb->prepare( "SELECT tabs_privacy FROM `{$meta_table}` WHERE user_id = %d", $user_id ), ARRAY_A );
44 + wp_cache_set( $obj_key, $row, 'uwp_usermeta_tabs_privacy' );
45 + }
59 46
60 - $settings = apply_filters( 'uwp_update_option', $settings, $key, $value );
61 - $settings = apply_filters( 'uwp_update_option_' . $key, $settings, $key, $value );
47 + $value = false;
62 48
63 - update_option( 'uwp_settings', $settings );
49 + if ( ! empty( $row ) ) {
50 + $public_fields = isset( $row['tabs_privacy'] ) ? maybe_unserialize( $row['tabs_privacy'] ) : $default;
51 + $public_fields_keys = is_array( $public_fields ) ? array_keys( $public_fields ) : $public_fields;
64 52
65 - return true;
66 - }
53 + if ( is_array( $public_fields ) && in_array( $key, $public_fields_keys ) ) {
54 + $value = $public_fields[ $key ];
55 + }
56 + }
57 + } else {
58 + $obj_key = $user_id.'_user_privacy';
59 + $row = wp_cache_get( $obj_key, 'uwp_usermeta_user_privacy' );
67 60
68 - /**
69 - * Gets UsersWP user meta value using key.
70 - *
71 - * @since 1.0.0
72 - * @package userswp
73 - *
74 - * @param int|bool $user_id User ID.
75 - * @param string $key User meta Key.
76 - * @param bool|string $default Default value.
77 - *
78 - * @return string User meta Value.
79 - */
80 - public function get_usermeta( $user_id = false, $key = '', $default = false ) {
81 - if (!$user_id) {
82 - return $default;
83 - }
61 + if ( ! $row ) {
62 + $row = $wpdb->get_row( $wpdb->prepare("SELECT user_privacy FROM `{$meta_table}` WHERE user_id = %d", $user_id ), ARRAY_A );
63 + wp_cache_set( $obj_key, $row, 'uwp_usermeta_user_privacy' );
64 + }
84 65
85 - $user_data = get_userdata($user_id);
86 - $value = null;
87 - $usermeta = false;
66 + $value = 'yes';
88 67
89 - if (!uwp_str_ends_with($key, '_privacy')) {
90 - if ($key == 'uwp_account_email') {
91 - $value = $user_data->user_email;
92 - } else {
93 - $usermeta = uwp_get_usermeta_row($user_id);
94 - if (!empty($usermeta)) {
95 - $value = $usermeta->{$key} ? $usermeta->{$key} : $default;
96 - } else {
97 - $value = $default;
98 - }
68 + if ( ! empty( $row ) ) {
69 + $output = isset( $row['user_privacy'] ) ? $row['user_privacy'] : $default;
70 + $public_fields = explode( ',', $output );
99 71
100 - }
101 - } else {
102 - $usermeta = uwp_get_usermeta_row($user_id);
103 - }
72 + if ( in_array( $key, $public_fields ) ) {
73 + $value = 'no';
74 + }
75 + }
76 + }
77 + } else {
78 + $value = null;
79 + $user_data = get_userdata( $user_id );
104 80
81 + if ( ! $user_data ) {
82 + return $value;
83 + }
105 84
106 - $value = uwp_maybe_unserialize($key, $value);
107 - $value = wp_unslash($value);
108 - $value = apply_filters( 'uwp_get_usermeta', $value, $user_id, $key, $default, $usermeta );
109 - return apply_filters( 'uwp_get_usermeta_' . $key, $value, $user_id, $key, $default, $usermeta );
110 - }
85 + switch ( $key ) {
86 + case 'email': $value = $user_data->user_email; break;
87 + case 'username': $value = $user_data->user_login; break;
88 + case 'user_nicename': $value = $user_data->user_nicename; break;
89 + case 'bio': $value = $user_data->description; break;
90 + case 'uwp_language': $value = $user_data->locale; break;
91 + default :
92 + $obj_key = $user_id.'_'.$key;
93 + $row = wp_cache_get( $obj_key, 'uwp_usermeta' );
111 94
95 + if ( ! $row ) {
96 + if ( in_array( $key, array( 'user_id', 'user_ip', 'user_privacy', 'tabs_privacy', 'username', 'email', 'first_name', 'last_name', 'avatar_thumb', 'banner_thumb', 'display_name', 'user_url', 'bio' ) ) || uwp_column_exist( $meta_table, $key ) ) {
97 + $row = $wpdb->get_row( $wpdb->prepare( "SELECT `{$key}` FROM `{$meta_table}` WHERE user_id = %d", $user_id ), ARRAY_A );
98 + wp_cache_set( $obj_key, $row, 'uwp_usermeta' );
99 + }
100 + }
101 +
102 + if ( ! empty( $row ) ) {
103 + $value = isset( $row[ $key ] ) ? $row[ $key ] : $default;
104 + } else {
105 + $value = $default;
106 + }
107 + break;
108 + }
109 + }
110 +
111 + $value = uwp_maybe_unserialize($key, $value);
112 + $value = wp_unslash($value);
113 + $value = apply_filters( 'uwp_get_usermeta', $value, $user_id, $key, $default );
114 +
115 + return apply_filters( 'uwp_get_usermeta_' . $key, $value, $user_id, $key, $default );
116 + }
117 +
112 118 /**
113 119 * Updates UsersWP user meta value using key.
114 120 *
115 121 * @since 1.0.0
@@ -120,57 +126,70 @@
120 126 * @param string $value User meta Value.
121 127 *
122 128 * @return bool Update success or not?.
123 129 */
124 - public function update_usermeta( $user_id = false, $key, $value ) {
130 + public function update_usermeta( $user_id, $key, $value ) {
131 + global $wpdb;
125 132
126 - if (!$user_id || !$key ) {
127 - return false;
128 - }
133 + if ( ! $user_id || ! $key ) {
134 + return false;
135 + }
129 136
130 - global $wpdb;
131 - $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
132 - $user_meta_info = uwp_get_usermeta_row($user_id);
137 + $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
138 + $cache_group = 'uwp_usermeta';
139 + $obj_key = $user_id . '_' . $key;
133 140
134 - $value = apply_filters( 'uwp_update_usermeta', $value, $user_id, $key, $user_meta_info );
135 - $value = apply_filters( 'uwp_update_usermeta_' . $key, $value, $user_id, $key, $user_meta_info );
141 + if ( ! in_array( $key, array( 'user_id', 'user_ip', 'user_privacy', 'tabs_privacy', 'username', 'email', 'first_name', 'last_name', 'avatar_thumb', 'banner_thumb', 'display_name', 'user_url', 'bio' ) ) && ! uwp_column_exist( $meta_table, $key ) ) {
142 + return false;
143 + }
136 144
137 - do_action( 'uwp_before_update_usermeta', $user_id, $key, $value, $user_meta_info );
145 + if ( uwp_str_ends_with( $key, '_privacy' ) ) {
146 + if ( 'tabs_privacy' == $key ) {
147 + $obj_key = $user_id . '_tabs_privacy';
148 + $cache_group = 'uwp_usermeta_tabs_privacy';
149 + } elseif('user_privacy' == $key) {
150 + $obj_key = $user_id . '_user_privacy';
151 + $cache_group = 'uwp_usermeta_user_privacy';
152 + }
153 + }
138 154
155 + $user_meta_info = $wpdb->get_col( $wpdb->prepare( "SELECT `{$key}` FROM `{$meta_table}` WHERE user_id = %d", $user_id ) );
139 156
140 - $value = uwp_maybe_serialize($key, $value);
157 + $value = apply_filters( 'uwp_update_usermeta', $value, $user_id, $key, $user_meta_info );
158 + $value = apply_filters( 'uwp_update_usermeta_' . $key, $value, $user_id, $key, $user_meta_info );
141 159
142 - if (uwp_str_ends_with($key, '_privacy')) {
143 - $key = 'user_privacy';
144 - }
160 + do_action( 'uwp_before_update_usermeta', $user_id, $key, $value, $user_meta_info );
145 161
146 - if (!empty($user_meta_info)) {
147 - $wpdb->query(
148 - $wpdb->prepare(
162 + $value = uwp_maybe_serialize( $key, $value );
149 163
150 - "update " . $meta_table . " set {$key} = %s where user_id = %d",
151 - array(
152 - $value,
153 - $user_id
154 - )
155 - )
156 - );
157 - } else {
158 - $wpdb->query(
159 - $wpdb->prepare(
164 + if ( ! empty( $user_meta_info ) ) {
165 + $result = $wpdb->update(
166 + $meta_table,
167 + array( $key => $value ),
168 + array( 'user_id' => $user_id ),
169 + array('%s'),
170 + array('%d')
171 + );
160 172
161 - "insert into " . $meta_table . " set {$key} = %s, user_id = %d",
162 - array(
163 - $value,
164 - $user_id
165 - )
166 - )
167 - );
168 - }
173 + if ( ! $result ) {
174 + return false;
175 + }
176 + } else {
177 + $result = $wpdb->insert(
178 + $meta_table,
179 + array( 'user_id' => $user_id, $key => $value )
180 + );
169 181
170 - return true;
171 - }
182 + if ( ! $result ) {
183 + return false;
184 + }
185 + }
172 186
187 + wp_cache_delete( $obj_key, $cache_group );
188 +
189 + return true;
190 + }
191 +
173 192 /**
174 193 * Gets UsersWP user meta row using user ID.
175 194 *
176 195 * @since 1.0.0
@@ -187,9 +206,13 @@
187 206
188 207 global $wpdb;
189 208 $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
190 209
191 - $row = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$meta_table} WHERE user_id = %d", $user_id));
210 + $row = wp_cache_get( $user_id, 'uwp_usermeta_row' );
211 + if ( ! $row ) {
212 + $row = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$meta_table} WHERE user_id = %d", $user_id));
213 + wp_cache_set( $user_id, $row, 'uwp_usermeta_row' );
214 + }
192 215
193 216 return $row;
194 217 }
195 218
@@ -209,9 +232,17 @@
209 232 }
210 233
211 234 global $wpdb;
212 235 $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
213 - $wpdb->query($wpdb->prepare("DELETE FROM {$meta_table} WHERE user_id = %d", $user_id));
236 +
237 + $count = $wpdb->query($wpdb->prepare("DELETE FROM {$meta_table} WHERE user_id = %d", $user_id));
238 +
239 + if ( ! $count ) {
240 + return false;
241 + }
242 +
243 + wp_cache_delete( $user_id, 'uwp_usermeta_row' );
244 +
214 245 }
215 246
216 247 /**
217 248 * Syncs WP usermeta with UsersWP usermeta.
@@ -224,17 +255,42 @@
224 255 * @return void
225 256 */
226 257 public function sync_usermeta($user_id) {
227 258
259 + global $wpdb;
228 260 $user_data = get_userdata($user_id);
261 + $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
229 262
230 - uwp_update_usermeta($user_id, 'uwp_account_username', $user_data->user_login);
231 - uwp_update_usermeta($user_id, 'uwp_account_email', $user_data->user_email);
232 - uwp_update_usermeta($user_id, 'uwp_account_display_name', $user_data->display_name);
233 - uwp_update_usermeta($user_id, 'uwp_account_first_name', $user_data->first_name);
234 - uwp_update_usermeta($user_id, 'uwp_account_last_name', $user_data->last_name);
235 - uwp_update_usermeta($user_id, 'uwp_account_bio', $user_data->description);
263 + $user_meta = array(
264 + 'username' => $user_data->user_login,
265 + 'email' => $user_data->user_email,
266 + 'display_name' => $user_data->display_name,
267 + 'first_name' => $user_data->first_name,
268 + 'last_name' => $user_data->last_name,
269 + 'user_url' => $user_data->user_url,
270 + 'bio' => $user_data->description,
271 + );
236 272
273 + foreach ($user_meta as $key => $meta){
274 + do_action('sync_usermeta_on_register', $user_id, $key, $meta); // for adding points via mycred add on.
275 + }
276 +
277 + $users = $wpdb->get_var($wpdb->prepare("SELECT COUNT(user_id) FROM {$meta_table} WHERE user_id = %d", $user_id));
278 +
279 + if($users){
280 + $wpdb->update(
281 + $meta_table,
282 + $user_meta,
283 + array('user_id' => $user_id)
284 + );
285 + } else {
286 + $user_meta['user_id'] = $user_id;
287 + $wpdb->insert(
288 + $meta_table,
289 + $user_meta
290 + );
291 + }
292 +
237 293 }
238 294
239 295 /**
240 296 * Delete UsersWP meta when user get deleted.
@@ -296,94 +352,15 @@
296 352 *
297 353 * @return void
298 354 */
299 355 public function save_user_ip_on_login( $user_login, $user ) {
300 -
301 - $ip = uwp_get_ip();
302 356 if (isset($user->ID)) {
357 + $ip = uwp_get_ip();
303 358 uwp_update_usermeta($user->ID, 'user_ip', $ip);
304 359 }
305 360 }
306 361
307 362 /**
308 - * Modifies privacy value while updating into the db.
309 - *
310 - * @since 1.0.0
311 - * @package userswp
312 - * @param string $value Privacy value.
313 - *
314 - * @param int $user_id The User ID.
315 - * @param string $key Custom field key.
316 - * @param object $user_meta_info User meta row.
317 - *
318 - * @return string Modified privacy field string.
319 - */
320 - public function modify_privacy_value_on_update($value, $user_id, $key, $user_meta_info) {
321 - if (uwp_str_ends_with($key, '_privacy')) {
322 - $old_value = $user_meta_info->user_privacy;
323 - if (!empty($old_value)) {
324 - // Existing serialized value
325 - if ($value == 'no') {
326 - $public_fields = explode(',', $old_value);
327 - if (!in_array($key, $public_fields)) {
328 - $public_fields[] = $key;
329 - }
330 - $value = implode(',', $public_fields);
331 - } else {
332 - // Yes value
333 - $public_fields = explode(',', $old_value);
334 - if(($key = array_search($key, $public_fields)) !== false) {
335 - unset($public_fields[$key]);
336 - }
337 - $value = implode(',', $public_fields);
338 - }
339 -
340 - } else {
341 - // New Serialized value
342 - if ($value == 'no') {
343 - $public_fields = array();
344 - $public_fields[] = $key;
345 - $value = implode(',', $public_fields);
346 - } else {
347 - // For yes values no need to update since its a public field.
348 - // We store only the private fields.
349 - }
350 -
351 - }
352 - }
353 - return $value;
354 - }
355 -
356 - /**
357 - * Modifies privacy value while fetching from the db.
358 - *
359 - * @since 1.0.0
360 - * @package userswp
361 - *
362 - * @param string $value Privacy value.
363 - * @param int $user_id The User ID.
364 - * @param string $key Custom field key.
365 - * @param string $default Default value.
366 - *
367 - * @return string Modified privacy value.
368 - */
369 - public function modify_privacy_value_on_get($value, $user_id, $key, $default, $usermeta) {
370 - if (uwp_str_ends_with($key, '_privacy')) {
371 - $value = 'yes';
372 - if (!empty($usermeta)) {
373 - $output = $usermeta->user_privacy ? $usermeta->user_privacy : $default;
374 - if ($output) {
375 - $public_fields = explode(',', $output);
376 - if (in_array($key, $public_fields)) {
377 - $value = 'no';
378 - }
379 - }
380 - }
381 - }
382 - return $value;
383 - }
384 -
385 - /**
386 363 * Modifies date value from unix timestamp to string while updating into the db.
387 364 *
388 365 * @since 1.0.0
389 366 * @package userswp
@@ -393,16 +370,18 @@
393 370 * @param string $key Custom field key.
394 371 *
395 372 * @return string Date string.
396 373 */
397 - public function modify_datepicker_value_on_update($value, $user_id, $key) {
398 - // modify timestamp to date
399 - if (is_int($value)) {
400 - $field_info = uwp_get_custom_field_info($key);
401 - if ($field_info->field_type == 'datepicker') {
402 - $value = date('Y-m-d', $value);
374 + public function modify_datepicker_value_on_update( $value, $user_id, $key ) {
375 + // Modify timestamp to date
376 + if ( is_int( $value ) ) {
377 + $field_info = uwp_get_custom_field_info( $key );
378 +
379 + if ( ! empty( $field_info ) && $field_info->field_type == 'datepicker' ) {
380 + $value = date( 'Y-m-d', $value );
403 381 }
404 382 }
383 +
405 384 return $value;
406 385 }
407 386
408 387 /**
@@ -416,114 +395,40 @@
416 395 * @param string $key Custom field key.
417 396 *
418 397 * @return int Unix Timestamp.
419 398 */
420 - public function modify_datepicker_value_on_get($value, $user_id, $key, $default, $usermeta) {
399 + public function modify_datepicker_value_on_get($value, $user_id, $key, $default) {
421 400 // modify date to timestamp
422 - if (is_string($value) && (strpos($value, '-') !== false)) {
423 - $field_info = uwp_get_custom_field_info($key);
424 - if (isset($field_info->field_type) && $field_info->field_type == 'datepicker') {
425 - $value = strtotime($value);
426 - }
427 - }
401 + $field_info = uwp_get_custom_field_info($key);
402 + if (isset($field_info->field_type) && $field_info->field_type == 'datepicker') {
403 + if (is_string($value) && (strpos($value, '-') !== false) && $value != '0000-00-00') {
404 + $value = strtotime( $value );
405 + } elseif($value === '0000-00-00'){$value = '';}
406 + }
407 +
428 408 return $value;
429 409 }
430 410
431 - public function uwp_user_row_actions($actions, $user_object){
432 - $user_id = $user_object->ID;
433 - $mod_value = get_user_meta( $user_id, 'uwp_mod', true );
434 - $delete_link = add_query_arg(
435 - array(
436 - 'user_id' => $user_id,
437 - 'action' => 'uwp_resend',
438 - '_nonce' => wp_create_nonce('uwp_resend'),
439 - ),
440 - admin_url( 'users.php' )
441 - );
442 - if ($mod_value == 'email_unconfirmed') {
443 - $actions['uwp_resend_activation'] = "<a class='' href='" . $delete_link . "'>" . __( 'Resend Activation','ultimate-member') . "</a>";
444 - }
411 + /**
412 + * Make UWP user meta available through the standard get_user_meta() function if prefixed with `user_`
413 + *
414 + * @param $metadata
415 + * @param $object_id
416 + * @param $meta_key
417 + * @param $single
418 + *
419 + * @return bool|mixed|null|string
420 + */
421 + public static function dynamically_add_user_meta( $metadata, $object_id, $meta_key, $single ) {
445 422
446 - return $actions;
447 - }
423 + if ( strpos( $meta_key, 'uwp_meta_' ) === 0 ) {
424 + $meta_key = substr( $meta_key, 9 );
425 + $maybe_meta = uwp_get_usermeta( $object_id, $meta_key, $single );
426 + if ( ! empty( $maybe_meta ) ) {
427 + $metadata = $maybe_meta;
428 + }
429 + }
448 430
449 - public function uwp_process_user_actions(){
450 - $user_id = isset($_REQUEST['user_id']) ? (int)$_REQUEST['user_id'] : 0;
451 - $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false;
452 - $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : false;
453 -
454 - if($user_id && 'uwp_resend' == $action && wp_verify_nonce( $nonce,'uwp_resend')){
455 - $send_result = $this->uwp_resend_activation_mail($user_id);
456 - if(!is_admin()){
457 - global $uwp_notices;
458 -
459 - if($send_result) {
460 - $message = __('Activation email has been sent!', 'userswp');
461 - } else {
462 - $message = __('Error while processing request. Please contact site admin.', 'userswp');
463 - }
464 - $uwp_notices[] = '<div class="uwp-alert-success text-center">'.$message.'</div>';
465 - return;
466 - }
467 - if(!$send_result){
468 - wp_redirect( add_query_arg( 'update', 'err_uwp_resend', admin_url('users.php') ) );
469 - }
470 - wp_redirect( add_query_arg( 'update', 'uwp_resend', admin_url('users.php') ) );
471 - exit();
472 - }
473 - }
474 -
475 - public function uwp_users_bulk_actions($bulk_actions){
476 - $bulk_actions['uwp_resend'] = __( 'Resend Activation', 'userswp');
477 - return $bulk_actions;
478 - }
479 -
480 - public function uwp_handle_users_bulk_actions($redirect_to, $doaction, $user_ids){
481 - if ( 'uwp_resend' !== $doaction ) {
482 - return $redirect_to;
483 - }
484 -
485 - foreach ( $user_ids as $user_id ) {
486 - $this->uwp_resend_activation_mail($user_id);
487 - }
488 -
489 - $redirect_to = add_query_arg( 'update', 'uwp_resend', $redirect_to );
490 - return $redirect_to;
491 - }
492 -
493 - public function uwp_resend_activation_mail($user_id = 0){
494 - if(!$user_id){
495 - return false;
496 - }
497 - if( 'email_unconfirmed' == get_user_meta( $user_id, 'uwp_mod', true )){
498 - $email = new UsersWP_Mails();
499 - $send_result = $email->send( 'activate', $user_id );
500 - return $send_result;
501 - }
502 - return true;
503 - }
504 -
505 - public function uwp_show_update_messages(){
506 - if ( !isset($_REQUEST['update']) ) return;
507 -
508 - $update = $_REQUEST['update'];
509 - $messages = array();
510 -
511 - switch($update) {
512 - case 'uwp_resend':
513 - $messages['msg'] = __('Activation email has been sent!','userswp');
514 - break;
515 - case 'err_uwp_resend':
516 - $messages['err_msg'] = __('Error while sending activation email. Please try again.','userswp');
517 - break;
518 - }
519 -
520 - if ( !empty( $messages ) ) {
521 - if ( isset($messages['err_content'])) {
522 - echo '<div class="notice notice-error"><p>' . $messages['err_msg'] . '</p></div>';
523 - } else {
524 - echo '<div class="notice notice-success is-dismissible"><p>' . $messages['msg'] . '</p></div>';
525 - }
526 - }
527 - }
431 + return $metadata;
432 + }
528 433
529 434 }