一种方法是,在提交注册表时,为“角色”定义一个值,然后将其传递给wp_insert_user Codex.
像这样:
$fields_user = get_fields_user(); //get the values from the form and put them in an array.
$fields_user[\'role\'] = \'participant\'; //define a value for the key \'role\'
$user_id = wp_insert_user($fields_user); //get all the info and register it with the wp_insert_user
但该角色必须已在管理员中创建