Created
March 21, 2017 20:00
-
-
Save marcosnakamine/f9be7bd3ca848af3bca7461cc0ab1600 to your computer and use it in GitHub Desktop.
WordPress - Add new user with custom role
This file contains hidden or 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 | |
add_action( 'wp_loaded', 'add_role_client' ); | |
function add_role_client() { | |
add_role( 'client', 'Client', array( | |
'read' => true | |
) ); | |
} |
This file contains hidden or 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 | |
$id_client = wp_insert_user( array( | |
'user_login' => 'user_name', | |
'user_pass' => 'strong_password', | |
'user_email' => '[email protected]', | |
'role' => 'client' | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment