php - How can I create a unique Wordpress username with Userpro plugin and its facebook connect? -



php - How can I create a unique Wordpress username with Userpro plugin and its facebook connect? -

i using userpro plugin register new users. want utilize facebook connect feature.

problem

it registers username facebook username email address. unfortunately means email address on display in profile url.

are these next solutions possible, , if how can alter code below create happen?

i wordpress username first half of email plus sort of random number @ end of avoid duplicates.

e.g. john.smith@gmail.com becomes john.smith536

or

i wordpress username unique random mix of numbers or letters (to avoid duplicates).

/* facebook connect */ add_action('wp_ajax_nopriv_userpro_fbconnect', 'userpro_fbconnect'); add_action('wp_ajax_userpro_fbconnect', 'userpro_fbconnect'); function userpro_fbconnect(){ global $userpro; $output = ''; if (!isset($_post)) die(); if ($_post['action'] != 'userpro_fbconnect') die(); if (!isset($_post['id'])) die(); if (!isset($_post['username']) || $_post['username'] == '' || $_post['username'] == 'undefined') { $username = $_post['email']; } else { $userame = $_post['username']; } /* check if facebook uid exists */ if (isset($_post['id']) && $_post['id'] != '' && $_post['id'] != 'undefined'){ $users = get_users(array( 'meta_key' => 'userpro_facebook_id', 'meta_value' => $_post['id'], 'meta_compare' => '=' )); if (isset($users[0]->id) && is_numeric($users[0]->id) ){ $returning = $users[0]->id; $returning_user_login = $users[0]->user_login; } else { $returning = ''; } } else { $returning = ''; } $result=get_user_meta($returning,"userpayment"); $paymentoption=get_option('userpro_payment');

thank help.

php wordpress facebook wordpress-plugin

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -