Home › Forums › WC Vendors Pro Support › Custom Fields in Settings Page
NOTICE: We've Moved to a Ticket System for Support
As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system. This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.
For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.
If you are a WC Vendors Pro customer please open a support ticket here. If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.
The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.
Thank you to all of our customers!
- This topic has 25 replies, 9 voices, and was last updated 7 years, 8 months ago by Anna.
-
AuthorPosts
-
November 16, 2015 at 1:30 pm #15564Bharath23Participant
Hello Ben,
I am trying to add a custom field to capture the vendor’s bank details. The box appears but the data entered is not getting saved. After I click “save”, when I go back to the payment tab on the settings page, I cant see the data i entered.
I used this code which you had shared with someone else –
add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_bank_name_field’);
function pv_add_custom_bank_name_field() {
?>
<div class=”pv_bank_name_container”>
<p><b><?php _e( ‘Bank Name’, ‘wc_product_vendor’ ); ?></b><br/>
<?php _e( ‘Your Local Bank Name.’, ‘wc_product_vendor’ ); ?><br/><input type=”text” name=”pv_bank_name” id=”pv_bank_name” placeholder=”First Bank” value=”<?php echo get_user_meta( get_current_user_id(), ‘pv_bank_name’, true ); ?>” />
</p>
</div>
<?php
}
add_action( ‘wcvendors_admin_after_commission_due’, ‘pv_admin_user_info’ );
function pv_admin_user_info( $user ) {
?>
<tr>
<th><label for=”pv_bank_name”><?php _e( ‘Bank Name’, ‘wc_product_vendor’ ); ?></label></th>
<td><input type=”text” name=”pv_bank_name” id=”pv_bank_name” value=”<?php echo get_user_meta( $user->ID, ‘pv_bank_name’, true ); ?>” class=”regular-text”></td>
</tr>
<?php
}
add_action( ‘wcvendors_shop_settings_saved’, ‘pv_save_bank_name’ );
add_action( ‘wcvendors_update_admin_user’, ‘pv_save_bank_name’ );
function pv_save_bank_name( $user_id )
{
if ( isset( $_POST[‘pv_bank_name’] ) ) {
update_user_meta( $user_id, ‘pv_bank_name’, $_POST[‘pv_bank_name’] );
}
}Please can you tell me if I am missing something. Thank you!
Kind regards,
BharathNovember 16, 2015 at 6:45 pm #15580WC Vendors SupportParticipantLooks like those filters are missing in Pro that save the settings (wcvendors_update_admin_user & wcvendors_shop_settings_saved).
Your code is good, it’s not you, it’s us. 🙂
We’ll have this patched for v1.1.0 which is finishing up testing right now and prepping for release within 24 hrs. When you update to v1.1.0, it will work just fine.
November 17, 2015 at 1:49 am #15601JamieKeymasterHello,
The above code is applicable to our free plugin, not the pro plugin. In pro as we don’t store information with the user, it is saved to the store which is its own post type. In our next release ANY custom field that starts with ‘_wcv_custom_settings_’ will automatically be saved to the database and you don’t have to hook into the action at all.
This gist is the new way of doing things, create the new form input, have the id start with _wcv_custom_settings_ and everything else is created for you and saved for you.
https://gist.github.com/digitalchild/9fe913cd140931a0cc6b
If you do want to hook into the action for saving custom data on the store setting page you can call the following action:
wcv_pro_store_settings_saved
cheers,
Jamie.
November 18, 2015 at 2:34 pm #15815SheldonParticipantHow I would save this information to the vendor store in the wp-admin?
November 20, 2015 at 10:14 am #16115CriterioNetParticipantThe site admin where you view the data in these new fields?
November 20, 2015 at 2:20 pm #16135WC Vendors SupportParticipantI think Jamie would have to code in something to allow that to show up on the Vendor Store wp-admin listing. @digitalchild
November 25, 2015 at 6:59 am #16685Bharath23ParticipantSorry Ben, can you help me with this?
After the vendor has updated their bank details, I am not able to view it as the admin.Is there a way I can get this data?
November 25, 2015 at 11:37 am #16705WC Vendors SupportParticipantYou make a good point. What good is saving it if you can not see it? @digitalchild will have to code this up.
For now, install: https://wordpress.org/plugins/user-switching/ and go to wp-admin > users > vendors > hover over the vendor and “switch to” them. Then go to the Pro Dashboard and view the bank information.
Ben
December 14, 2015 at 4:57 pm #18468WC Vendors SupportParticipantI must have misunderstood this the first time I read it.
If you add a custom field, and you use the KnowledgeBase article for it, you will see code in there that will make it show up on the users page. It’s up to you to code this, we cant just magically detect any custom fields you do use, and automatically show them. We’re good at PHP, but we aint Willy Wonka. 😉
December 15, 2015 at 7:38 am #18516CriterioNetParticipantHi @ben, you think then it will not be possible to show custom fields in admin panel?
December 15, 2015 at 11:51 am #18543WC Vendors SupportParticipantYou can show any data anywhere you want. It’s just a matter of writing the code for it.
May 4, 2016 at 5:42 am #31472XehonParticipantHello, is there a way to set up a mask on one of these new fields ?
I mean, when user type his SWIFT or another specific code, it would be apropriate to avoid any typing mistake !May 4, 2016 at 10:24 am #31491WC Vendors SupportParticipantThere’s no masking in Pro, no…
May 4, 2016 at 10:32 am #31494AndyParticipantHi I had this working correctly for a while now and haven’t changed anything except replacing the code that goes into WCV > templates > dashboard > store-settings.php after the update being that to was overridden in 3.0.
I have two custom fields for banking data placed within the “Payment Methods” tab underneath the PayPal address field, both fields including the entered data are still visible and when save is hit gives conformation, when I view the input data in the User’s account page again both fields are available but the second field is missing its data along with the string of code which was added in functions.php.
See highlighted screenshots.
Any help would be greatly appreciated.
Andy
functions.php
/* WC Vendors Pro – My Custom Bank Fields */
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überweisung als Auszahlungs Methode Ihres Provision verwenden’, ‘wcvendors-pro’ ),
‘placeholder’ => __( ‘Bank Name’, ‘wcvendors-pro’ ),
‘desc_tip’ => ‘true’,
‘description’ => __( ‘Bankinstitut’, ‘wcvendors-pro’ ),
‘type’ => ‘text’,
‘value’ => $value,
)
);
}
}
function store_iban_details( ){
if ( class_exists( ‘WCVendors_Pro’ ) ){
$key = ‘_wcv_custom_settings_ibanname’;
$value = get_user_meta( get_current_user_id(), $key, true );
// iban Name
WCVendors_Pro_Form_Helper::input( array(
‘id’ => $key,
‘label’ => __( ‘IBAN Nummer bitte nicht vergessen’, ‘wcvendors-pro’ ),
‘placeholder’ => __( ‘IBAN NUMMER’, ‘wcvendors-pro’ ),
‘desc_tip’ => ‘true’,
‘description’ => __( ‘IBAN Nummer’, ‘wcvendors-pro’ ),
‘type’ => ‘text’,
‘value’ => $value,
)
);
}
}
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>
add_action( ‘wcvendors_admin_after_store_bank_details’, ‘wcv_store_iban_details_admin’ );
function wcv_store_iban_details_admin( $user ) {
?>
<tr>
<th><label for=”_wcv_custom_settings_iban”><?php _e( ‘IBAN NUMMER’, ‘wcvendors-pro’ ); ?></label></th>
<td><input type=”text” name=”_wcv_custom_settings_iban” id=”_wcv_custom_settings_iban” value=”<?php echo get_user_meta( $user->ID, ‘_wcv_custom_settings_iban’, true ); ?>” class=”regular-text”></td>
</tr>
<?php
}
?>May 4, 2016 at 10:35 am #31499WC Vendors SupportParticipantAndy: You did a crappy copy and paste job. 🙂
https://www.wcvendors.com/members/ukstang/media/1090/ — The part in yellow? You forgot to begin the add_action line with
<?php
Without PHP open/close tags, it just outputs text. 🙂May 4, 2016 at 11:01 am #31510AndyParticipantIts always worked till yesterday after the 3.0 update, so I’m not too sure if your answer is correct 🙁
I’m not saying you’re wrong with the <?php tags but I tried that and it just gives out an error. The code I am using (apart from the naming edits) is the same as the example in the Knowledge Base Pro #19.May 4, 2016 at 11:35 am #31513WC Vendors SupportParticipant</tr> add_action( ‘wcvendors_admin_after_store_bank_details’, ‘wcv_store_iban_details_admin’ ); function wcv_store_iban_details_admin( $user ) { ?>
Should be:
</tr> <?php add_action( 'wcvendors_admin_after_store_bank_details', 'wcv_store_iban_details_admin' ); function wcv_store_iban_details_admin( $user ) { ?>
Remember, you can also click the code tag in replies to make formatting code easier to read on the forums here. 😉
May 4, 2016 at 1:49 pm #31541AndyParticipantHi Ben,
as soon as I add the <?php function I get an error message… what I don’t get is that it was working fine before and also in singular mode it works correctly in 3.0 too, by singular mode I mean that I’m adding two fields “Bank” & “IBAN”. The bank field alone works fine without the <?php and even when the IBAn field is re-added too, its just that there after the IBAN outputs the code in the Admin User page, the IBAN field but without the data.
I also tried your suggestion in the Storefront theme but had the same problem.
May 4, 2016 at 5:05 pm #31570WC Vendors SupportParticipant@ukstang can you add the code you are using to gist.github.com and paste a link to it here? Since you arent formatting the code properly, it’s just an epic fail as far as reading it and the quotes and stuff. I’ll take a peek once you do!
May 4, 2016 at 6:19 pm #31575AndyParticipantThanks I appreciate it.
https://gist.github.com/anonymous/0d3a59a594b74087ae9098485037f73b
May 4, 2016 at 8:35 pm #31583WC Vendors SupportParticipantThanks. Now compare my version. You’ll see the problem. 🙂
https://gist.github.com/bentasm1/f68212e0e7c0d0e13b6818623182d21c
May 5, 2016 at 4:40 am #31601AndyParticipantThanks Ben, what a difference a curley bracket can make but to be honest being a PHP NULL I tried placing exactly as you first described and thats what was causing the error.
Now all is still not good and well because now that no error is visible it doesn’t save the IBAN field to the database at the Admin UserPage. I feel terrible asking but as I said it was all working how its was, before 3.0, I have data in fields from prior pseudo vendor accounts to prove it.
So it saves the IBAN field on the Vendors settings page but not in the Admin Users page.May 5, 2016 at 8:26 pm #31655WC Vendors SupportParticipantThat’s because you told the wp-admin screen to show it, but not to allow any edits to it. I’ve updated the code 2 posts up with the extra filters/functions to save the iban and bankname details when in wp-admin on the user edit screen. 😉
May 6, 2016 at 3:53 am #31671AndyParticipantHey Ben thanks for this I do appreciate it, very much so 🙂
Now if only we could get cool whip in Austria my day would be complete 😉
August 20, 2016 at 10:52 pm #40610JamesParticipantHI, Ben, I still very new to wordpress, so I still confuse with the steps above. My problem still the same, wanna add some custom field like Andy in WC-Vendor Pro, and I have add the code you stated in my onesocial child theme, the code is as follow
/* WC Vendors Pro – My Custom Bank Fields */
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überweisung als Auszahlungs Methode Ihres Provision verwenden’, ‘wcvendors-pro’ ),
‘placeholder’ => __( ‘Bank Name’, ‘wcvendors-pro’ ),
‘desc_tip’ => ‘true’,
‘description’ => __( ‘Bankinstitut’, ‘wcvendors-pro’ ),
‘type’ => ‘text’,
‘value’ => $value,
)
);
}
}
function store_iban_details( ){
if ( class_exists( ‘WCVendors_Pro’ ) ){
$key = ‘_wcv_custom_settings_ibanname’;
$value = get_user_meta( get_current_user_id(), $key, true );
// iban Name
WCVendors_Pro_Form_Helper::input( array(
‘id’ => $key,
‘label’ => __( ‘IBAN Nummer bitte nicht vergessen’, ‘wcvendors-pro’ ),
‘placeholder’ => __( ‘IBAN NUMMER’, ‘wcvendors-pro’ ),
‘desc_tip’ => ‘true’,
‘description’ => __( ‘IBAN Nummer’, ‘wcvendors-pro’ ),
‘type’ => ‘text’,
‘value’ => $value,
)
);
}
}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_admin_after_commission_due’, ‘wcv_store_iban_details_admin’ );
function wcv_store_iban_details_admin( $user ) {
?>
<tr>
<th><label for=”_wcv_custom_settings_iban”><?php _e( ‘IBAN NUMMER’, ‘wcvendors-pro’ ); ?></label></th>
<td><input type=”text” name=”_wcv_custom_settings_iban” id=”_wcv_custom_settings_iban” value=”<?php echo get_user_meta( $user->ID, ‘_wcv_custom_settings_iban’, true ); ?>” class=”regular-text”></td>
</tr>
<?php
}
// This saves the _wcv_custom_settings_iban when on the wp-admin > users > edit user screen
add_action( ‘wcvendors_update_admin_user’, ‘iban_details_save’ );
function iban_details_save( $user_id )
{
if ( isset( $_POST[‘_wcv_custom_settings_iban’] ) ) {
update_user_meta( $user_id, ‘_wcv_custom_settings_iban’, $_POST[‘_wcv_custom_settings_iban’] );
}
}
// And repeating this but with the next meta key
add_action( ‘wcvendors_update_admin_user’, ‘bankname_details_save’ );
function bankname_details_save( $user_id )
{
if ( isset( $_POST[‘_wcv_custom_settings_bankname’] ) ) {
update_user_meta( $user_id, ‘_wcv_custom_settings_bankname’, $_POST[‘_wcv_custom_settings_bankname’] );
}
}Then, I aslo add this code, <?php store_bank_details( $key ); ?> (you can see in the photo below)
to the store-settings.php in the following path, public_html/wp-content/themes/onesocial-child/wc-vendors-pro/templates/dashboard/store-settings.php,but no luck, in the seller profile, the payment still didnt show anything.
Hope for your response
August 20, 2016 at 11:04 pm #40615AnnaMemberPlease see my reply in your other thread: https://www.wcvendors.com/help/topic/fail-to-set-custom-fields-to-shop-settings-page/
-
AuthorPosts
- The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.