Home / Admin / Custom Field to Vendor Settings Page
Duplicate Snippet

Embed Snippet on Your Site

Custom Field to Vendor Settings Page

Code Preview
php
<?php
/* 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, 
			)
		);
	} 
}
add_action( 'wcvendors_admin_after_bank_details', 'wcv_store_bank_details_admin' );
function wcv_store_bank_details_admin( $user ) {
?>
  <tr>
    <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>
  </tr>
<?php
}
// 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'] );
 }
}
?>

Comments

Add a Comment