Creating a members only e-commerce website with pre-set users and having controll over the new users approval? Using WooCommerce with its registration form with a few added fields does the job perfectly. The only issue is that when a user completes the form, WooCommerce checks for empty fields and logs the user in straight away, skipping the administration approval. Why dont we add ‘New User Approve‘?

The code below doesn’t need changing, you need to have WP Approve User installed and active, the rest can be “copy – paste” in your functions.php. Please, read the code and follow my explanation below:

The actions gets called once the woocommerce form is submited and checked. The user data is stored in the database which is followed by the function that checks if the user has been approved by the admin ( This is why we used WP Approve User). If its not, it signs the user out it and notifies by echoing a message on the page, showing that the user registration status is on ‘pending’ and it needs to be approved before being able to log in.

Removing auto generated password by New User Approve

To prevent some future confusion with the automatically generated password, the plugin provides a solution to disable creating one and leaving that in user’s hands. It usually triggers itself when the user is activated and it overrides the custom password added by the user in the registration process. You might also need to check the e-mail templates and remove/retouch that message there as well. For more help, don’t hesitate to contact me!


 

If you find my blogging useful, please share it.