1. Home
  2. WC Vendors Pro
  3. How To
  4. Custom Fields to Vendor Settings Page (Pro)

Custom Fields to Vendor Settings Page (Pro)

This code adds a custom field to the Dashboard > Settings page for your vendors to provide you extra bits of info you may need from them. Duplicate for each custom field you need, renaming the meta keys and functions each time so they are not duplicated.  For WC Vendors Pro, the updates you need to make are in three parts as described below.

Part 1:  Add this code to your theme’s functions.php file:

/* WC Vendors Pro - My Custom Field */
function store_bank_details( ){ 
	if ( class_exists( 'WCVendors_Pro' ) ){ 
		$key = '_wcv_custom_settings_bankname'; 
		$value = get_user_meta( get_current_user_id(), $key, true ); 
		// Bank Name
		WCVendors_Pro_Form_Helper::input( array(  
			'id' 				=> $key, 
			'label' 			=> __( 'Bank Name', 'wcvendors-pro' ), 
			'placeholder' 			=> __( 'First Bank', 'wcvendors-pro' ), 
			'desc_tip' 			=> 'true', 
			'description' 			=> __( 'Your local bank name', 'wcvendors-pro' ), 
			'type' 				=> 'text', 
			'value'				=> $value, 

Part 2: This adds the custom field to the wp-admin > Users > Edit User screen, if you need it to, and also goes in your theme’s functions.php file:

add_action( 'wcvendors_admin_after_bank_details', 'wcv_store_bank_details_admin' );
function wcv_store_bank_details_admin( $user ) {
    <th><label for="_wcv_custom_settings_bankname"><?php _e( 'Bank Name Custom', 'wcvendors-pro' ); ?></label></th>
    <td><input type="text" name="_wcv_custom_settings_bankname" id="_wcv_custom_settings_bankname" value="<?php echo get_user_meta( $user->ID, '_wcv_custom_settings_bankname', true ); ?>" class="regular-text"></td>

// Save the details on the back end when updating the user
add_action( 'personal_options_update', 'save_bank_details' );
add_action( 'edit_user_profile_update', 'save_bank_details' );
function save_bank_details( $user_id ){
 if ( isset( $_POST['_wcv_custom_settings_bankname'] ) ) {
 update_user_meta( $user_id, '_wcv_custom_settings_bankname', $_POST['_wcv_custom_settings_bankname'] );

Part 3: In order to show the custom field on your Pro Settings page, you need to add the function you just created above to the template. Copy /plugins/wc-vendors-pro/templates/dashboard/store-settings.php to /themes/yourtheme-child/wc-vendors/dashboard/store-settings.php and add this wherever you want the field to show up.

<?php store_bank_details(  ); ?>


Updated on January 28, 2021

Was this article helpful?