wordpress get username
$current_user = wp_get_current_user();
echo($current_user->user_login);
wordpress get username
$current_user = wp_get_current_user();
echo($current_user->user_login);
wordpress register user php
<php
// register
$user = (isset($_POST['username']) ? $_POST['username'] : '');
$pass = (isset($_POST['password']) ? $_POST['password'] : '');
$email = (isset($_POST['email']) ? $_POST['email'] : '');
if (!username_exists($user) && !email_exists($email)) {
$user_id = wp_create_user($user, $pass, $email);
if (!is_wp_error($user_id)) {
//user has been created
$user = new WP_User($user_id);
$user->set_role('do');
//Redirect
wp_redirect('URL_where_you_want_redirect');
exit;
} else {
//$user_id is a WP_Error object. Manage the error
}
}else{
// user exist
}
?>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us