PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 3.0.8
Wp Social Login and Register Social Counter v3.0.8
3.2.1 trunk 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.4 1.4.5 1.4.6 1.4.8 1.4.9 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.8 2.2.9 3.0.0 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0
wp-social / inc / admin-create-user.php
wp-social / inc Last commit date
elementor 3 years ago admin-create-shortcode.php 7 years ago admin-create-user.php 1 year ago admin-custom-function.php 3 years ago admin-rest-api.php 5 years ago admin-settings.php 1 year ago admin-social-button.php 3 years ago admin-social-enque-script.php 5 years ago counter-widget.php 3 years ago counter.php 3 years ago custom-function.php 5 years ago login-widget.php 3 years ago login.php 5 years ago share-widget.php 3 years ago share.php 3 years ago
admin-create-user.php
855 lines
1 <?php
2
3 use WP_Social\App\Settings;
4 use WP_Social\App\Login_Settings;
5 use WP_Social\Lib\Login\Line_App;
6
7 defined('ABSPATH') || exit;
8
9 /**
10 * session stat for current redirect URL after login from social.
11 *
12 * @since : 1.0
13 */
14 session_start();
15
16
17 if(isset($_GET['XScurrentPage']) and strlen(sanitize_url($_GET['XScurrentPage'])) > 2) {
18
19 $_SESSION['xs_social_login_ref_url'] = sanitize_url($_GET['XScurrentPage']);
20 $_SESSION['xs_social']['login_ref_url'] = sanitize_url($_GET['XScurrentPage']);
21 }
22
23 //wordpress default redirect_to param
24 if(!empty($_GET['redirect_to'])) {
25
26 $_SESSION['xs_social']['redirect_to'] = urldecode(sanitize_url($_GET['redirect_to']));
27 }
28
29
30 /**
31 * Variable Name: $currentURL
32 * Variable Details: get Current URL from session data after login by social
33 *
34 * @since : 1.0
35 */
36 $currentURL = isset($_SESSION['xs_social_login_ref_url']) ? sanitize_url($_SESSION['xs_social_login_ref_url']) : get_site_url();
37
38 /**
39 * Wp Function: is_user_logged_in();
40 * Function Details: check user login. If user is login after redirect current URL by $currentURL
41 *
42 * @since : 1.0
43 */
44
45 if(is_user_logged_in()) {
46 if(wp_redirect($currentURL)) {
47 exit;
48 }
49 }
50
51 /**
52 * Variable Name : $xs_config
53 * Variable Type : Array
54 *
55 * @since : 1.0
56 */
57 $xs_config = [];
58
59 if(!empty($typeSocial)) {
60 if($typeSocial == 'lineapp' && !empty($code)){
61 create_line_app_user($code, $typeSocial);
62 }
63
64 /**
65 * Variable Name : $provider_data
66 * Variable Type : Array
67 * @return : array() $provider_data . Get array from socail provider data ""
68 *
69 * @since : 1.0
70 */
71 $provider_data = Settings::get_login_settings_data();
72
73 /**
74 * Variable Name : $callBackUrl
75 * Variable Type : String
76 * Variable Details : Create dynamic callback URL for all social services.
77 *
78 * @since : 1.0
79 */
80 $callBackUrl = get_site_url() . '/wp-json/wslu-social-login/type/' . $typeSocial;
81
82 /**
83 * Variable Name : $serviceType
84 * Variable Type : Array
85 * @return : array(). Get array from custom function page "admin-custom-function.php"
86 *
87 * @since : 1.0
88 */
89 $serviceType = \WP_Social\App\Providers::get_core_providers_login();
90
91 /**
92 * check array key from $serviceType by social type . For Example: facebook
93 *
94 * @since : 1.0
95 */
96 if(array_key_exists($typeSocial, $serviceType)) {
97 $socialType = $serviceType[$typeSocial];
98
99 if($typeSocial == 'linkedin') {
100 $socialType = 'LinkedInOpenID';
101 }
102 }
103
104 /**
105 * API configration for Facebook, Twitter, Linkedin, Dribble, Pinterest, Wordpress, Instagram, GitHub, Vkontakte and Reddit
106 *
107 * @since : 1.0
108 */
109
110 /**
111 * Set callback URL in array "$xs_config" for configration API
112 *
113 * @since : 1.0
114 */
115 $xs_config['callback'] = $callBackUrl;
116
117 /**
118 * Create array for API Providers for all service using foreach by variable "$serviceType"
119 *
120 * @since : 1.0
121 */
122 foreach($serviceType as $serviceKey => $serviceValue) :
123 $idData = 'id';
124 if($serviceKey == 'twitter') {
125 $idData = 'key';
126 }
127
128 $config_para = [
129 'enabled' => true,
130 'keys' => [
131 $idData => isset($provider_data[$serviceKey]['id']) ? $provider_data[$serviceKey]['id'] : '',
132 'secret' => isset($provider_data[$serviceKey]['secret']) ? $provider_data[$serviceKey]['secret'] : '',
133 ],
134 ];
135
136 if( $serviceKey == 'linkedin' ) {
137 $config_para['scope'] = 'openid profile email'; // optional //Linkedin openid connect scope
138 }
139
140 if( $serviceKey == 'linkedin' ) {
141 $xs_config['providers']['LinkedInOpenID'] = $config_para;
142 }else{
143 $xs_config['providers'][$serviceValue] = $config_para;
144 }
145
146 endforeach;
147 }
148
149
150 /**
151 * Config API
152 *
153 * @since : 1.0
154 */
155 $code = isset($_GET['code']) ? sanitize_text_field($_GET['code']) : '';
156
157 if(strlen($socialType) > 0) {
158
159 try {
160 $hybridauth = new Hybridauth\Hybridauth($xs_config);
161
162 $adapter = $hybridauth->authenticate($socialType);
163
164 $isConnected = $adapter->isConnected();
165
166 if($isConnected) :
167 $getProfile = $adapter->getUserProfile();
168
169 if(is_object($getProfile) && !empty($getProfile)) {
170
171 $user_email = isset($getProfile->email) ? $getProfile->email : '';
172 $emailVerified = !empty($getProfile->emailVerified);
173 if ($emailVerified || empty($user_email)) {
174
175 /**
176 * Variable Name : $setting_data
177 * Variable Type : Array
178 * @return : array() $setting_data . Get array from social global setting data "xs_global_setting_data"
179 *
180 * @since : 1.0
181 */
182 $setting_data = get_option(\WP_Social\Keys::OK_GLOBAL_SETTINGS);
183
184 /**
185 * Resolve it before resetting the session
186 */
187 $final_redirect = resolve_redirect_url($_SESSION, $setting_data);
188
189
190 /**
191 * Now cleaning the session
192 *
193 */
194 xs_login_session_handaler();
195
196 $avatar_obj = \WP_Social\App\Avatar::instance();
197
198 $first_name = $avatar_obj->get_nice_name($getProfile, $socialType);
199 $last_name = $avatar_obj->get_last_name($getProfile, $socialType);
200 $s_user_key = $avatar_obj->get_username($getProfile, $socialType);
201 $display_nm = $avatar_obj->get_display_name($getProfile, $socialType);
202 $user_email = $getProfile->email;
203 $description = $getProfile->description;
204
205 $user_info = $avatar_obj->get_linked_user($s_user_key, $socialType);
206
207 $user = false;
208 if (isset($user_info['username'])) {
209 $user = get_user_by('login', $user_info['username']);
210 }
211
212 if ( !$user) {
213
214 /**
215 * This is a registration process
216 * this user never? had registered with us
217 *
218 * Lets check if user's social profile email is existed in our system
219 * If it does we just let him log in
220 */
221 $user_id = email_exists($user_email);
222
223 if($user_id) {
224
225 $user_nameD = xs_login_get_user_data_email($user_email, 'user_login');
226
227 $avatar_obj->update_linked_user($s_user_key, $socialType, ['id' => $user_id, 'usr' => $user_nameD]);
228
229 xs_user_login($user_nameD, $final_redirect);
230
231 die('Most unlikely error occurred in your case.');
232 }
233
234 /**
235 * It turns out this user does not used his email in our system
236 * So lets make him a new username for login
237 *
238 */
239 $user_nm = $avatar_obj->get_available_username($getProfile, $socialType);
240
241 /**
242 * Grabbing the default role settings for new user
243 * Though it is working with wp_insert_user still adding this as per Ataur bhai
244 *
245 */
246 $default_role = get_option('default_role', '');
247
248 $insertData = [];
249 $insertData['first_name'] = $first_name;
250 $insertData['last_name'] = $last_name;
251 $insertData['user_nicename'] = $user_nm;
252 $insertData['user_email'] = $user_email;
253 $insertData['display_name'] = $display_nm;
254 $insertData['description'] = $description;
255
256 /**
257 * User does not exists with prepared username or
258 * email from social site in our system
259 *
260 * Save the image from social site a attachment
261 * lets make a random password
262 * now create a new user
263 *
264 */
265 $password = wp_generate_password();
266 $insertData['user_login'] = $user_nm;
267 $insertData['user_pass'] = $password;
268 $insertData['role'] = $default_role;
269
270 /**
271 * Make the avatar url
272 * and save the image as attachment
273 */
274 $avatar_url = $avatar_obj->get_avatar_url($getProfile, $socialType);
275 if(get_option('wp_social_login_sync_image_too') == 'yes') {
276 $attach = save_image_from_url_as_attachment($avatar_url);
277 }else{
278 $attach['error'] = true;
279 }
280
281 //$checkUser = xs_login_create_user($insertData);
282 $checkUser = xs_social_create_user($insertData);
283
284 if($checkUser > 0) {
285 /**
286 * User created successful
287 * Update user meta
288 * Notify admin a new user has been created
289 * Notify user? [AR: a customer asked!]
290 *
291 */
292
293 if(empty($attach['error'])) {
294
295 update_user_meta($checkUser, 'xs_social_register_by', $socialType);
296 update_user_meta($checkUser, 'xs_social_profile_image', $attach['url']);
297 update_user_meta($checkUser, 'xs_social_profile_image_id', $attach['attachment_id']);
298 } else {
299 update_user_meta($checkUser, 'xs_social_profile_image', '');
300 update_user_meta($checkUser, 'xs_social_profile_image_error_log', $socialType . '::' . $attach['error']);
301 }
302
303 $avatar_obj->update_linked_user($s_user_key, $socialType, ['id' => $checkUser, 'usr' => $user_nm]);
304
305 /**
306 * As we have created the user with a random password and they are registering with social credential
307 * so there is no use of change of password
308 */
309 update_user_meta($checkUser, 'xs_password_changed', 'yes');
310
311 notify_new_user_to_user($insertData);
312
313 $wp_social_login_settings = get_option('xs_global_setting_data');
314
315 if (isset($wp_social_login_settings['email_new_registered_user']['enable']) && $wp_social_login_settings['email_new_registered_user']['enable'] == 1) {
316 notify_new_user_to_admin($checkUser, $socialType);
317 }
318
319 xs_user_login($user_nm, $final_redirect);
320
321 die('Most most unlikely error occurred in your case. user registration done but login failed!!');
322 }
323
324 die('New user creation failed!');
325
326 } else {
327
328 $id = $user->data->ID;
329
330 update_user_meta($id, 'xs_social_register_by', $socialType);
331
332 if(get_option('wp_social_login_sync') == 'yes') {
333
334
335 update_user_meta($id, 'first_name', $first_name);
336 update_user_meta($id, 'last_name', $last_name);
337 update_user_meta($id, 'display_name', $display_nm);
338 update_user_meta($id, 'description', $description);
339
340
341 if(get_option('wp_social_login_sync_image_too') == 'yes') {
342 $avatar_url = $avatar_obj->get_avatar_url($getProfile, $socialType);
343 $current_avatar_url = get_user_meta($id, 'xs_social_profile_image', true);
344
345 $attach = [];
346
347 if($current_avatar_url != $avatar_url) {
348
349 $attach = save_image_from_url_as_attachment($avatar_url);
350 }
351
352 if(!empty($attach) && empty($attach['error'])) {
353
354 $existing_attachment_id = get_user_meta($id, 'xs_social_profile_image_id', true);
355
356 if (!empty($existing_attachment_id)) {
357 wp_delete_attachment($existing_attachment_id, true);
358 }
359 update_user_meta($id, 'xs_social_profile_image', $attach['url']);
360 update_user_meta($id, 'xs_social_profile_image_id', $attach['attachment_id']);
361 }
362 }
363 }
364
365 /**
366 * Proceeding to login
367 *
368 */
369
370 $user_name = $user_info['username'];
371
372 xs_user_login($user_name, $final_redirect);
373
374 die('Most unlikely error occurred in your case.');
375 }
376 } else {
377 // Email not verified or not provided
378 die('Email address is not verified or not provided by the social provider.');
379 }
380
381 } else {
382 die('System Error for Callback!');
383 }
384
385 endif;
386
387 $adapter->disconnect();
388
389 } catch(\Exception $e) {
390 echo esc_html('Oops, we ran into an issue!' . $e->getMessage());
391 }
392 }
393
394
395 /**
396 * Function Name : xs_login_create_user();
397 * Function Details : create new user from socail login and check enable wp new create new users.
398 *
399 * @params : array() $userdata. For user information
400 *
401 * @return : int() if success then user id else 0
402 *
403 * @since : 1.0
404 */
405
406 function xs_login_create_user($userdata) {
407
408 // todo - permission checking removed for registering user : consult with CTO
409
410 $user_id = wp_insert_user($userdata);
411
412 if(!is_wp_error($user_id)) {
413
414 update_user_meta($user_id, 'xs_password_changed', 'no');
415
416 return $user_id;
417 }
418
419 return 0;
420 }
421
422
423 add_action('init', 'xs_login_create_user');
424
425 /**
426 * Function Name : xs_login_get_user_data();
427 * Function Details : Get user information when user already exists into database
428 *
429 * @params : String() $loginName. User login name
430 *
431 * @return : String() User information by set filed from database table.
432 *
433 * @since : 1.0
434 */
435 function xs_login_get_user_data($loginName, $getFiled = 'user_login') {
436 $users = get_user_by('login', $loginName);
437 if(empty($users)) {
438 return '';
439 }
440
441 return $users->data->$getFiled;
442 }
443
444
445 /**
446 *
447 * @since 1.3.8
448 *
449 * @param $loginName
450 * @param string $field
451 *
452 * @return string
453 */
454 function xs_login_get_user_field($loginName, $field = 'user_login') {
455
456 $users = get_user_by('login', $loginName);
457
458 if(empty($users)) {
459 return '';
460 }
461
462 return $users->data->$field;
463 }
464
465
466 add_action('init', 'xs_login_get_user_data');
467
468 /**
469 * Function Name : xs_login_get_user_data_email();
470 * Function Details : Get user information when email already exists into database
471 *
472 * @params : String() $email. User login name
473 *
474 * @return : String() User information by set filed from database table.
475 *
476 * @since : 1.0
477 */
478 function xs_login_get_user_data_email($email, $getFiled = 'user_login') {
479 $users = get_user_by('email', $email);
480 if(empty($users)) {
481 return '';
482 }
483
484 return $users->data->$getFiled;
485 }
486
487
488 add_action('init', 'xs_login_get_user_data');
489 /**
490 * Function Name : xs_user_login();
491 * Function Details : User login function by wp_signon();
492 *
493 * @params : String() $user_name. User login name
494 * @params : String() $password. User password
495 *
496 * @return : True | False
497 *
498 * @since : 1.0
499 */
500 function xs_user_login($user_name, $redirect_to = '') {
501 if(strlen($user_name) == 0) {
502 die('User name is empty!');
503 }
504
505 $username = $user_name;
506 $user = get_user_by('login', $username);
507
508
509 if(!is_wp_error($user)) {
510 wp_clear_auth_cookie();
511 wp_set_current_user($user->ID);
512 wp_set_auth_cookie($user->ID);
513
514 $redirect_to = empty($redirect_to) ? user_admin_url() : $redirect_to;
515 wp_safe_redirect($redirect_to);
516 exit();
517 }
518 }
519
520
521 add_action('init', 'xs_user_login');
522
523
524 /**
525 * Get file extension fro a image that is rendering from a php url
526 *
527 * @since 1.0.0
528 *
529 * @param $url
530 *
531 * @return array|string
532 */
533 function get_file_ext_from_url($url) {
534
535 $extension = '';
536 $headers = wp_get_http_headers($url);
537 $mime_type = $headers['content-type'];
538
539 foreach(wp_get_mime_types() as $ext => $mime) {
540 if($mime == $mime_type) {
541
542 $extension = explode('|', $ext);
543
544 return $extension[0];
545 }
546 }
547
548 return $extension;
549 }
550
551
552 /**
553 * Save a image php url as a attachment of post
554 *
555 * @since 1.0.0
556 *
557 * @param $url
558 * @param string $unique_name - name with extension
559 * @param int $post_id - default 0
560 *
561 * @return array
562 */
563 function save_image_from_url_as_attachment($url, $unique_name = '', $post_id = 0) {
564
565 require_once(ABSPATH . "wp-admin" . '/includes/image.php');
566 require_once(ABSPATH . "wp-admin" . '/includes/file.php');
567 require_once(ABSPATH . "wp-admin" . '/includes/media.php');
568
569 $ext = get_file_ext_from_url($url);
570 $tmp = download_url($url);
571
572 $name = empty($unique_name) ? '__tmp_' . time() . '.' . $ext : $unique_name;
573
574 $file_array = array(
575 'name' => $name,
576 'tmp_name' => $tmp,
577 );
578
579
580 /**
581 * Check for download errors
582 * if there are error unlink the temp file name
583 */
584 if(is_wp_error($tmp)) {
585 @unlink($file_array['tmp_name']);
586
587 return [
588 'error' => $tmp->get_error_message(),
589 ];
590 }
591
592 /**
593 * now we can actually use media_handle_sideload
594 * we pass it the file array of the file to handle
595 * and the post id of the post to attach it to
596 * $post_id can be set to '0' to not attach it to any particular post
597 */
598 $id = media_handle_sideload($file_array, $post_id);
599
600 /**
601 * We don't want to pass something to $id
602 * if there were upload errors.
603 * So this checks for errors
604 */
605 if(is_wp_error($id)) {
606 @unlink($file_array['tmp_name']);
607
608 return [
609 'error' => $id->get_error_message(),
610 ];
611 }
612
613 /**
614 * No we can get the url of the sideloaded file
615 * $value now contains the file url in WordPress
616 * $id is the attachment id
617 */
618 $value = wp_get_attachment_url($id);
619
620
621 return [
622 'url' => $value,
623 'attachment_id' => $id,
624 ];
625 }
626
627
628 function xs_login_session_handaler() {
629
630 session_unset();
631
632 // do we ever need the below?
633 if(isset($_SESSION['xs_social_login_ref_url'])) {
634 unset($_SESSION['xs_social_login_ref_url']);
635 }
636 }
637
638
639 /**
640 *
641 * @since 1.3.7
642 *
643 * @param $user_info
644 *
645 * @return int
646 */
647 function xs_social_create_user($user_info) {
648
649 do_action('wslu_social/before_create_user');
650
651 /*
652 * todo - ask Ataur bhai - do we allow insert user without permission with social? it make sense to do so
653 *
654 */
655 $getPermissionRegisterWP = get_option('users_can_register', 0);
656
657 if($getPermissionRegisterWP == 0) {
658
659 // return 0;
660 }
661
662 $user_id = wp_insert_user($user_info);
663
664 if(is_wp_error($user_id)) {
665
666 return 0;
667 }
668
669
670 return $user_id;
671 }
672
673
674 /**
675 * Checking the parameter and settings to find the correct redirect url
676 *
677 * @since 1.3.8
678 *
679 * @param $session
680 * @param $setting
681 *
682 * @return string
683 */
684 function resolve_redirect_url($session, $setting) {
685
686 /**
687 * First priority to wordpress default redirect_to param
688 * Second priority to custom login settings url
689 * Third priority to XScurrentPage param [AR : not sure where it is used though!]
690 * And lastly site home page
691 *
692 */
693
694 if(!empty($session['xs_social']['redirect_to'])) {
695
696 $final_redirect = $session['xs_social']['redirect_to'];
697
698 } elseif(!empty($setting['custom_login_url']['enable']) && !empty($setting['custom_login_url']['data'])) {
699
700 $final_redirect = $setting['custom_login_url']['data'];
701
702 } elseif(!empty($session['xs_social']['login_ref_url'])) {
703
704 $final_redirect = $session['xs_social']['login_ref_url'];
705
706 } else {
707
708 $final_redirect = user_admin_url();
709 }
710
711 return $final_redirect;
712 }
713
714
715 /**
716 *
717 * @since 1.3.8
718 *
719 */
720 function clear_social_session_data() {
721
722 if(!empty($_SESSION['xs_social'])) {
723
724 unset($_SESSION['xs_social']);
725 }
726 }
727
728
729 /**
730 *
731 * @since 1.3.7
732 *
733 * @param $user_id
734 *
735 * @return mixed
736 */
737 function notify_new_user_to_admin($user_id, $social_type) {
738
739 wp_new_user_notification($user_id, null, 'both');
740
741 return true;
742 }
743
744
745 /**
746 *
747 * @since 1.3.7
748 *
749 *
750 * @param array $info_array
751 *
752 * @return bool
753 */
754 function notify_new_user_to_user($info_array = []) {
755
756 /*
757 * todo - complete it after discussion
758 */
759
760 return true;
761 }
762
763
764 function create_line_app_user($code, $socialType) {
765
766 $lineapp = new Line_App();
767 $user = $lineapp->get_user_info($code);
768
769 if (empty($user->email)) {
770 die('Please allow line app email permission');
771 }
772
773 $login_settings_obj = new Login_Settings();
774 $login_global_settings = $login_settings_obj->get_global_settings();
775 $final_redirect = (isset( $login_global_settings['custom_login_url'] ) && isset( $login_global_settings['custom_login_url']['enable'] ) && isset( $login_global_settings['custom_login_url']['data'] )) ? $login_global_settings['custom_login_url']['data'] : get_site_url() . '/wp-admin';
776
777 $old_user = get_user_by('email', $user->email);
778
779 if ($old_user == false) {
780 $default_role = get_option('default_role', '');
781 $nicename = $user->name . time();
782 $password = wp_generate_password();
783
784 $insertData = [
785 'first_name' => $user->name,
786 'user_nicename' => $nicename,
787 'user_email' => $user->email,
788 'display_name' => $user->name,
789 'user_login' => $user->email,
790 'user_pass' => $password,
791 'role' => $default_role
792 ];
793
794 $attach = isset($user->picture) ? save_image_from_url_as_attachment($user->picture) : '';
795
796 $user_id = xs_social_create_user($insertData);
797
798 if ($user_id > 0) {
799
800 //if image not save for this user then attach will be empty
801 if( !empty($attach) ){
802 if (empty($attach['error'])) {
803
804 update_user_meta($user_id, 'xs_social_register_by', $socialType);
805 update_user_meta($user_id, 'xs_social_profile_image', $attach['url']);
806 update_user_meta($user_id, 'xs_social_profile_image_id', $attach['attachment_id']);
807 } else {
808 update_user_meta($user_id, 'xs_social_profile_image', '');
809 update_user_meta($user_id, 'xs_social_profile_image_error_log', $socialType . '::' . $attach['error']);
810 }
811 }
812 $wp_social_login_settings = get_option('xs_global_setting_data');
813
814 if (isset($wp_social_login_settings['email_new_registered_user']['enable']) && $wp_social_login_settings['email_new_registered_user']['enable'] == 1) {
815 notify_new_user_to_admin($user_id, $socialType);
816 }
817
818 xs_user_login($user->email, $final_redirect);
819
820 die('Most most unlikely error occurred in your case. user registration done but login failed!!');
821 }
822 } else {
823
824 $id = $old_user->data->ID;
825
826 update_user_meta($id, 'xs_social_register_by', $socialType);
827
828 if (get_option('wp_social_login_sync') == 'yes') {
829
830
831 update_user_meta($id, 'first_name', $user->name);
832 update_user_meta($id, 'display_name', $user->name);
833
834
835 if(get_option('wp_social_login_sync_image_too') == 'yes') {
836 $attach = save_image_from_url_as_attachment($user->picture);
837
838 if (empty($attach['error'])) {
839 wp_delete_attachment(get_user_meta($id, 'xs_social_profile_image_id'));
840 update_user_meta($id, 'xs_social_profile_image', $attach['url']);
841 update_user_meta($id, 'xs_social_profile_image_id', $attach['attachment_id']);
842 }
843 }
844 }
845
846 /**
847 * Proceeding to login
848 *
849 */
850
851 xs_user_login($old_user->data->user_login, $final_redirect);
852
853 die('Most unlikely error occurred in your case.');
854 }
855 }