[ad_1]
hi @vandehee,
We currently do not have that feature on vendor dedicated registration page, I’ll raise a feature request for this.
Having said that, what you can do is create a custom registration form and have it automatically assign the vendor role and then a custom code to activate the vendor role.
You may need to use a 3rd party plugin that allows you to create a form and assigned certain roles when registering through the form, also please reach out to said plugin support team going forward as you may need to tweak the snippets:
if ( ! function_exists( 'wcv_update_vendor_status' ) ) {
/**
* Update vendor status
*
* @param int $user_id the user id.
*/
function wcv_update_vendor_status( $user_id ) {
$user = get_user_by( 'id', $user_id );
if ( in_array( 'vendor', $user->roles, true ) ) {
update_user_meta( $user_id, '_wcv_vendor_status', 'active' );
}
}
add_action( 'user_register', 'wcv_update_vendor_status', 10, 1 );
}or
if ( ! function_exists( 'wcv_update_vendor_status_on_add_role' ) ) {
/**
* Update vendor status on add role
*
* @param int $user_id the user id.
* @param string $role the new role.
*/
function wcv_update_vendor_status_on_add_role( $user_id, $role ) {
if ( 'vendor' === $role ) {
update_user_meta( $user_id, '_wcv_vendor_status', 'active' );
}
}
add_action( 'add_user_role', 'wcv_update_vendor_status_on_add_role', 10, 2 );
}
