Is it possible to create automatically a product after a user registers?
I'm creating a sort of marketplace, so when a user signs up as vendor, I want Woocommerce to automatically create a product with these specs:
Product name = Booking - the_author_meta ('display_name')
Product slug = calendar-the_author_meta ('user_login')
For example. John Doe registers as vendor with "username: johndoe". When the registration is complete, a product is automatically created.
The product name is " Booking - John Doe". The product slug is: "calendar-johndoe".
So the product Booking - John Doe can be found at mysite.com/product/calendar-johndoe
Thank you for your time
Here is the code:
Code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.
The code is tested and fully functional.
Please Note: I have assumed that your registration form has
first_name
andlast_name
field otherwise if you are using default WooCommerce registration form then it only hasemail
andpassword
field, So then above code will generate a product name asBooking -
.Hope this helps!