I have a custom form so the user can register at my site.

He can register as a subscriber or as a shop.

I need to 'block' all registrations for shop, so the user register as a shop, receives an email telling him that the registration is on hold, the admin receives an email telling him a new shop registered, and the admin approves the registration in the admin panel.

Any ideas on how to do that? I've searched for a plugin, but some of them forced me to use their own registration forms and others prevented any role from registering.

What I have so far is a regular registration form that I created. One for the shops and one for the subscribers. It works perfectly.

up vote 1 down vote accepted

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

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.