Created
November 7, 2012 01:43
-
-
Save tcelestino/4029038 to your computer and use it in GitHub Desktop.
Adiciona um novo usuário
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// salva um usuario no wordpress | |
// return @interger | |
function save_user($avatar, $username, $name, $email) { | |
if(empty($username)) { | |
$username = "Guest_".rand(000000,999999).$username; // cria um usuario caso não tenha um nome de usuário | |
} | |
$userdata = array( | |
"ID" => '', | |
"user_pass" => wp_generate_password(), | |
'user_login' => $username, | |
'user_nicename' => $name, | |
'user_url' => '', | |
'user_email' => $email, | |
'display_name' => $name, | |
'nickname' => $username, | |
'first_name' => $name, | |
'user_registered' => '', | |
'role' => get_option('default_role') | |
); | |
$profile_id = wp_insert_user($userdata); | |
if($profile_id) { | |
if(empty($avatar)) { | |
$avatar = ""; | |
} else { | |
add_user_meta($profile_id, "_avatar_facebook", $avatar, true); | |
} | |
return $profile_id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment