Skip to content

Instantly share code, notes, and snippets.

@marcosnakamine
Created March 21, 2017 20:00
Show Gist options
  • Save marcosnakamine/f9be7bd3ca848af3bca7461cc0ab1600 to your computer and use it in GitHub Desktop.
Save marcosnakamine/f9be7bd3ca848af3bca7461cc0ab1600 to your computer and use it in GitHub Desktop.
WordPress - Add new user with custom role
<?php
add_action( 'wp_loaded', 'add_role_client' );
function add_role_client() {
add_role( 'client', 'Client', array(
'read' => true
) );
}
<?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