好吧,我找到了一个方法。这不是一个完美的解决方案,但可以让我继续这个项目。
我刚刚创建了另一个名为“shop\\u pending”的角色。
当用户注册为店铺时,他不会得到角色“shop”,而是得到角色“shop\\u pending”。
完成所有过程后,管理员可以转到用户页面,编辑特定用户,并更改其角色。
下面是我正在使用的部分代码:
// Check args and replace if necessary
if (!is_array($fields_shop)) $fields_shop = array();
if (!is_wp_error($errors_shop)) $errors_shop = new WP_Error;
if (isset($_POST[\'submit_shop\'])) {
// Get fields from submitted form
$fields_shop = ds_get_fields_shop();
// Validate fields and produce errors
if (ds_validate_shop($fields_shop, $errors_shop)) {
// If successful, register user
$fields_shop[\'role\'] = \'shop_pending\';
$shop_id = wp_insert_user($fields_shop);
update_user_meta( $shop_id, \'user_avatar\', $fields_shop[\'user_avatar\'] );
update_user_meta( $shop_id, \'nome_shop\', $fields_shop[\'nome_shop\'] );
update_user_meta( $shop_id, \'cont_shop\', $fields_shop[\'cont_shop\'] );
update_user_meta( $shop_id, \'telefone_shop\', $fields_shop[\'telefone_shop\'] );
update_user_meta( $shop_id, \'zip\', $fields_shop[\'zip\'] );
update_user_meta( $shop_id, \'conselho2\', $fields_shop[\'conselho2\'] );
// Clear field data
$fields_shop = array();
}