Skip to content

Instantly share code, notes, and snippets.

@fervous
Last active November 14, 2018 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fervous/6e398122cd43be49ebf71adcb5b0849b to your computer and use it in GitHub Desktop.
Save fervous/6e398122cd43be49ebf71adcb5b0849b to your computer and use it in GitHub Desktop.
add banking field to wc vendors pro settings page and admin user page
/* This should be placed in your theme/child theme functions.php.
Creates the function for the fields to collect the info, and adds the fields
to the front-end store settings page (payments tab) and the admin user page. */
/* ADD FIELD TO FRONT END DASHBOARD / SETTINGS */
add_action( 'wcvendors_settings_after_paypal', 'store_bank_details' );
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,
)
);
}
}
/* ADD FIELDS TO WP ADMIN > USER PAGE */
add_action( 'wcvendors_admin_after_commission_due', 'wcv_store_bank_details_admin' );
function wcv_store_bank_details_admin( $user ) {
?>
<tr>
<th><label for="_wcv_custom_settings_bankname"><?php _e( 'Bank Name', '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>
</tr>
<?php
}
add_action( 'wcvendors_settings_after_paypal', 'store_bank_account_number' );
function store_bank_account_number( ){
if ( class_exists( 'WCVendors_Pro' ) ){
$key = '_wcv_custom_settings_bank_number';
$value = get_user_meta( get_current_user_id(), $key, true );
// Bank Account Number
WCVendors_Pro_Form_Helper::input( array(
'id' => $key,
'label' => __( 'Bank Account Number', 'wcvendors-pro' ),
'placeholder' => __( '000-0000-0000', 'wcvendors-pro' ),
'desc_tip' => 'true',
'description' => __( 'Your bank account number', 'wcvendors-pro' ),
'type' => 'text',
'value' => $value,
)
);
}
}
add_action( 'wcvendors_admin_after_commission_due', 'wcv_store_bank_number_admin' );
function wcv_store_bank_number_admin( $user ) {
?>
<tr>
<th><label for="_wcv_custom_settings_bank_number"><?php _e( 'Bank Account Number', 'wcvendors-pro' ); ?></label></th>
<td><input type="text" name="_wcv_custom_settings_bank_number" id="_wcv_custom_settings_bank_number" value="<?php echo get_user_meta( $user->ID, '_wcv_custom_settings_bank_number', true ); ?>" class="regular-text"></td>
</tr>
<?php
}
@BalancedDesigner
Copy link

Anna, do you mind customizing this code for another field like 'email' to the Store tab? I cannot follow how to edit this code to fit my needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment