Set user role, if an specific role created an user
Im Trying to set an user role. if an specific user role (sales-agents) create an user.
the created user should have the role b2b instead of customer
here is my try:
add_action( 'init', 'b2b_set_user_role' );
function b2b_set_user_role() {
if ( is_user_logged_in() wcb2bsa_has_role( get_current_user_id(), 'sales_agent' ) )
{
$user-remove_role( ‘customer’ );
$user-add_role( ‘b2b’ );
}
}
i hope someone can help me
Topic wp-create-user user-roles init Wordpress
Category Web