Home / Admin / Make All Users Vendors
Duplicate Snippet

Embed Snippet on Your Site

Make All Users Vendors

Code Preview
php
<?php
/**
 * Make all new user registrations Vendors. 
 */
add_filter( 'woocommerce_new_customer_data', 'wcv_woocommerce_new_user_data' );
function wcv_woocommerce_new_user_data( $data ){
    $data['role'] = 'vendor'; // the new default role
    return $data;
}
/**
 * Redirect the new registered user to the Vendor Dashboard 
 */
add_filter( 'woocommerce_registration_redirect', 'wcv_vendor_registration_redirect', 10, 1 ); 
function wcv_vendor_registration_redirect( $redirect_to ) {
	$vendor_redirect    = get_option( 'wcvendors_vendor_login_redirect', '' );
	$dashboard_page_ids = (array) get_option( 'wcvendors_dashboard_page_id', array() );
	$dashboard_page_id  = reset( $dashboard_page_ids );
	$redirect_to = apply_filters( 'wcv_vendor_login_redirect_url', get_permalink( $dashboard_page_id ), $dashboard_page_id, $dashboard_page_ids );
	return $redirect_to;
}

Comments

Add a Comment