Custom registration and pending approval

Ok, I found a way to do it. It’s not a perfect solution but will allow me to continue the project.

I just created another role called ‘shop_pending’.

When the user registers as a shop, he won’t get the role ‘shop’, instead he will get the role’ shop_pending’.

After all the process is done, the admin can go to the users page, edit the specific user, and change it’s role.

Here is part of the code I’m using:

// 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(); 
}