Home › Forums › WC Vendors Free Support › Custom Field Values not displaying
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 29 replies, 3 voices, and was last updated 8 years, 7 months ago by stardrive.
-
AuthorPosts
-
September 3, 2015 at 3:22 pm #8273stardriveParticipant
Dear Support,
Please, I created 3 custom fields using the procedure outlined in this forum. The custom fields appears in the back end and also in the front end store settings in my site.
When I enter values into the custom fields under store settings in the front end and click on Submit button, the custom fields are updated in the database and show up against the custom fields in the WC Vendors section of user profile in the back end. But, these values do not display against the custom fields in the front end when I go to Store Settings; the 3 Custom fields show empty values.
Please, assist
Regards,
Stardrive
September 4, 2015 at 1:06 pm #8312WC Vendors SupportParticipantThen you’re probably saving the the wrong meta keys or displaying the wrong meta keys or there is other errors in your code. Hard to really help, I have no idea what you’ve written. 😉
September 4, 2015 at 1:48 pm #8315stardriveParticipantHello Ben,
Below is the code I used to add Bank Name: (I used similar code to add the other 2 custom fields)
// ADD Bank Name Field to WC Vendors
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=”Sample 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_bank_name_info’ );
function pv_bank_name_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’] );
}
}September 4, 2015 at 3:11 pm #8322WC Vendors SupportParticipantThat code appears to be correct — at least at a quick glance. If it’s not working, you’ve got an issue with it somewhere you’ll have to debug it and see what it is.
September 4, 2015 at 3:32 pm #8324stardriveParticipantHi Ben,
As I wrote in my initial post, the issue is:
When I enter values into the custom fields under store settings in the front end and click on Submit button, the custom fields are updated in the database and show up against the custom fields in the WC Vendors section of user profile in the back end. But, these values do not display against the custom fields in the front end when I go to Store Settings; the 3 Custom fields show empty values.
The code for the three custom fields, Bank Name, Bank Account Number, and Account Name are:
// ADD Bank Name Field to WC Vendors
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=”Sample 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_bank_name_info’ );
function pv_bank_name_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’] );
}
}// ====================================================================================================
// ADD Bank Account Number Field to WC Vendors
add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_bank_account_number_field’);
function pv_add_custom_bank_account_number_field() {
?>
<div class=”pv_bank_account_number_container”>
<p><b><?php _e( ‘Bank Account Number’, ‘wc_product_vendor’ ); ?></b><br/>
<?php _e( ‘Your Account Number.’, ‘wc_product_vendor’ ); ?><br/><input type=”text” name=”pv_bank_account_number” id=”pv_bank_account_number” placeholder=”999999999999″ value=”<?php echo get_user_meta( get_current_user_id(), ‘pv_bank_account_number’, true ); ?>” />
</p>
</div>
<?php
}
add_action( ‘wcvendors_admin_after_commission_due’, ‘pv_bank_account_number_info’ );
function pv_bank_account_number_info( $user ) {
?>
<tr>
<th><label for=”pv_bank_account_number”><?php _e( ‘Bank Account Number’, ‘wc_product_vendor’ ); ?></label></th>
<td><input type=”text” name=”pv_bank_account_number” id=”pv_bank_account_number” value=”<?php echo get_user_meta( $user->ID, ‘pv_bank_account_number’, true ); ?>” class=”regular-text”></td>
</tr>
<?php
}
add_action( ‘wcvendors_shop_settings_saved’, ‘pv_save_bank_account_number’ );
add_action( ‘wcvendors_update_admin_user’, ‘pv_save_bank_account_number’ );
function pv_save_bank_account_number( $user_id )
{
if ( isset( $_POST[‘pv_bank_account_number’] ) ) {
update_user_meta( $user_id, ‘pv_bank_account_number’, $_POST[‘pv_bank_account_number’] );
}
}// ====================================================================================================
// ADD Bank Account Name Field to WC Vendors
add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_account_name_field’);
function pv_add_custom_account_name_field() {
?>
<div class=”pv_account_name_container”>
<p><b><?php _e( ‘Account Name’, ‘wc_product_vendor’ ); ?></b><br/>
<?php _e( ‘Your Account Name.’, ‘wc_product_vendor’ ); ?><br/><input type=”text” name=”pv_account_name” id=”pv_account_name” placeholder=”Account Owner” value=”<?php echo get_user_meta( get_current_user_id(), ‘pv_account_name’, true ); ?>” />
</p>
</div>
<?php
}
add_action( ‘wcvendors_admin_after_commission_due’, ‘pv_account_name_info’ );
function pv_account_name_info( $user ) {
?>
<tr>
<th><label for=”pv_account_name”><?php _e( ‘Account Name’, ‘wc_product_vendor’ ); ?></label></th>
<td><input type=”text” name=”pv_account_name” id=”pv_account_name” value=”<?php echo get_user_meta( $user->ID, ‘pv_account_name’, true ); ?>” class=”regular-text”></td>
</tr>
<?php
}
add_action( ‘wcvendors_shop_settings_saved’, ‘pv_save_account_name’ );
add_action( ‘wcvendors_update_admin_user’, ‘pv_save_account_name’ );
function pv_save_account_name( $user_id )
{
if ( isset( $_POST[‘pv_account_name’] ) ) {
update_user_meta( $user_id, ‘pv_account_name’, $_POST[‘pv_account_name’] );
}
}September 7, 2015 at 5:48 pm #8444stardriveParticipantHi Ben,
Please, any help on my last request?
Regards,
stardrive
September 7, 2015 at 5:50 pm #8445WC Vendors SupportParticipantNot really, no…… This is deep customization of WC Vendors. It’s up to you to write and fix your own code. =)
September 7, 2015 at 5:56 pm #8446stardriveParticipantHello Ben,
I just read this thread: https://www.wcvendors.com/help/topic/customer-becoming-a-vendor/
The user that initiated the thread wrote this tis: “And the second thing from vendor_dashboard/shop_settings/ when clicking submit nothing happens….”I am wondering if this bug could be responsible for the issue I am experiencing
Regards,
Stardrive
September 7, 2015 at 7:32 pm #8449WC Vendors SupportParticipantUnfortunately not, no……. That’s talking about a bug where vendors cant register if there’s not a Terms of Service page set, and completely unrelated to Shop Settings.
September 7, 2015 at 8:14 pm #8452stardriveParticipantHi Ben,
Thanks for your response.
Please, I still need some assistance from you on this issue. I have carried out some troubleshooting and I cannot trace the cause.
On my own, I was able to solve some other issues i had with your plugin; Also, you have done quite well in helping me to solve the rest.But, this particular issue is very key to me. Please, I would like you to kindly assist me to resolve this pressing issue. I would very much appreciate if you can help.
Thank you.
Regards,
Stardrive
September 7, 2015 at 11:29 pm #8460WC Vendors SupportParticipantHi Stardrive,
I don’t mean to sound unhelpful. The code is presented to you to get it working on your site. If it isnt working, you’ve done something wrong or are omitting something. Usually, it’s going to be an error in function names or typos in the code.
Fixing things on your site for you, of which are not part of the regular plugin and are heavily customized, is a paid service. So if you need us to login to your site to get it to work, we’d be happy to, but you’ll need to compensate for the time we take out of our day to do that. Our rates are quite reasonable:
September 8, 2015 at 4:32 am #8462stardriveParticipantHello Ben,
The code actually updates the custom fields in the database. Also, the values in the database are displayed when you view the vendor profile in wordpress admin dashboard.
But, these values are not displayed when a vendor goes to store settings in the front end; the field values are empty; meanwhile the field values are not empty in the database. This is the problem.
If this is still a paid service, I will make further attempts to resolve it myself. If I am still unable to resolve it, I will then contact you for such service.
Regards,
Stardrive
September 8, 2015 at 8:49 am #8466tafmakuraParticipantIt’s likely that you are saving and calling the updated meta incorrectly from the frontend Looking at your code I don’t see where the variable $user_id is defined there is also $user where is it defined??????????. in your code these should contain the user’s ID you wish to query. Below is an example where I get the current logged in user’s ID as the property.
<?php
$user = wp_get_current_user();
$user_id = $user->ID;$vendor_bank = get_user_meta( $user_id, ‘pv_bank_account_number’ , true);
echo $vendor_bank;
?>September 8, 2015 at 8:56 am #8468September 8, 2015 at 9:07 am #8471stardriveParticipantThank you so much, Tafmakura.
Please, where in the code below should I place your code (in http://pastebin.com/embed_iframe.php?i=tzMJZjFC)?
// ADD Bank Name Field to WC Vendors
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=”Sample 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_bank_name_info’ );
function pv_bank_name_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’] );
}
}
// ====================================================================================================
// ADD Bank Account Number Field to WC Vendors
add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_bank_account_number_field’);
function pv_add_custom_bank_account_number_field() {
?>
<div class=”pv_bank_account_number_container”>
<p><b><?php _e( ‘Bank Account Number’, ‘wc_product_vendor’ ); ?></b><br/>
<?php _e( ‘Your Account Number.’, ‘wc_product_vendor’ ); ?><br/>
<input type=”text” name=”pv_bank_account_number” id=”pv_bank_account_number” placeholder=”999999999999″ value=”<?php echo get_user_meta( get_current_user_id(), ‘pv_bank_account_number’, true ); ?>” />
</p>
</div>
<?php
}
add_action( ‘wcvendors_admin_after_commission_due’, ‘pv_bank_account_number_info’ );
function pv_bank_account_number_info( $user ) {
?>
<tr>
<th><label for=”pv_bank_account_number”><?php _e( ‘Bank Account Number’, ‘wc_product_vendor’ ); ?></label></th>
<td><input type=”text” name=”pv_bank_account_number” id=”pv_bank_account_number” value=”<?php echo get_user_meta( $user->ID, ‘pv_bank_account_number’, true ); ?>” class=”regular-text”></td>
</tr>
<?php
}
add_action( ‘wcvendors_shop_settings_saved’, ‘pv_save_bank_account_number’ );
add_action( ‘wcvendors_update_admin_user’, ‘pv_save_bank_account_number’ );
function pv_save_bank_account_number( $user_id )
{
if ( isset( $_POST[‘pv_bank_account_number’] ) ) {
update_user_meta( $user_id, ‘pv_bank_account_number’, $_POST[‘pv_bank_account_number’] );
}
}
// ====================================================================================================
// ADD Bank Account Name Field to WC Vendors
add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_account_name_field’);
function pv_add_custom_account_name_field() {
?>
<div class=”pv_account_name_container”>
<p><b><?php _e( ‘Account Name’, ‘wc_product_vendor’ ); ?></b><br/>
<?php _e( ‘Your Account Name.’, ‘wc_product_vendor’ ); ?><br/>
<input type=”text” name=”pv_account_name” id=”pv_account_name” placeholder=”Account Owner” value=”<?php echo get_user_meta( get_current_user_id(), ‘pv_account_name’, true ); ?>” />
</p>
</div>
<?php
}
add_action( ‘wcvendors_admin_after_commission_due’, ‘pv_account_name_info’ );
function pv_account_name_info( $user ) {
?>
<tr>
<th><label for=”pv_account_name”><?php _e( ‘Account Name’, ‘wc_product_vendor’ ); ?></label></th>
<td><input type=”text” name=”pv_account_name” id=”pv_account_name” value=”<?php echo get_user_meta( $user->ID, ‘pv_account_name’, true ); ?>” class=”regular-text”></td>
</tr>
<?php
}
add_action( ‘wcvendors_shop_settings_saved’, ‘pv_save_account_name’ );
add_action( ‘wcvendors_update_admin_user’, ‘pv_save_account_name’ );
function pv_save_account_name( $user_id )
{
if ( isset( $_POST[‘pv_account_name’] ) ) {
update_user_meta( $user_id, ‘pv_account_name’, $_POST[‘pv_account_name’] );
}
}September 8, 2015 at 9:13 am #8472tafmakuraParticipantBefore we paste Can you please paste properly formatted code in pastebin so that I can read it better and also please confirm that you are successfully saving info from your form to the database
September 8, 2015 at 9:22 am #8474stardriveParticipantPleaser, the code has been pasted in pastebin. See the link: http://pastebin.com/Xc5DjE0W
Yes, the form or field values are successfully saved to the database.
Thank you
September 8, 2015 at 11:18 am #8480WC Vendors SupportParticipantThanks @tafmakura for offering your assistance to Stardrive on this. Much appreciated. 🙂
September 8, 2015 at 11:46 am #8487tafmakuraParticipantWe will hook this code to the hook where we want the fields to display in the template (you must look at action hooks and filters to be able to place this where you want) In this case we are going to show the saved information in the My Account Page if the user is a vendor. Put the linked code in your functions.php
September 8, 2015 at 3:04 pm #8493tafmakuraParticipantThere is a mistake in the code above, the code won’t work, use this instead….
September 8, 2015 at 3:14 pm #8496WC Vendors SupportParticipantLine 7 & 8 on the gist need to be single quotes, not curly quotes.
September 8, 2015 at 4:56 pm #8505stardriveParticipantDear tafmakura,
Thank you so much.
Please, I used the code in https://gist.github.com/anonymous/01261f48dbbe28c53840 in my functions.php file, and replaced the curly quotes in Line 7 & 8 on the gist with single quotes as advised by Ben.
I got this error message when i logged in as a vendor and clicked on the My Accounts menu:
Fatal error: Call to undefined function wp_get_current_user_id() in /home1/domain_name/public_html/sub_directory/wp-content/themes/child-theme/functions.php on line 432
line 432 in functions.php is line 6 in the code in https://gist.github.com/anonymous/01261f48dbbe28c53840
which is:
$user_id = wp_get_current_user_id();I greatly appreciate your assistance.
Regards,
StardriveSeptember 8, 2015 at 4:59 pm #8506WC Vendors SupportParticipanthttps://codex.wordpress.org/Function_Reference/get_current_user_id
get_current_user_id is the right function name, wp_get_current_user_id does not exist.
September 8, 2015 at 5:23 pm #8507tafmakuraParticipantSorry about that, I copied meta keys in line 7 & 8 from your original code and I don’t know how wp_get_current_user_id slipped past.
Replace
wp_get_current_user_id
in line 6 withget_current_user_id
and that should work, sorry for the mistake on my part, line 6 should therefore be like this:
$user_id = get_current_user_id();
I hope now it works, good luck….September 8, 2015 at 6:06 pm #8510stardriveParticipantThank you so much, tafmakura. I am very grateful for your kind assistance.
The saved information (field values) is now showing in the My Account Page if the user is a vendor.
But, it is not showing in the corresponding fields (Account Name, Account Number) text boxes in the Shop Settings page. These field values are empty in the Shop Settings page. This was the original issue i raised.
Regards,
Stardrive
September 9, 2015 at 3:13 am #8514tafmakuraParticipantIn your original code where it says
$user->ID
Replace with
get_current_user_id
Remember to remove the curly ” and ‘. Where it says $user->ID your function is expecting a user ID but it is not getting it, this
get_current_user_id
gets the current ID, that’s all we changed.September 9, 2015 at 4:15 am #8518stardriveParticipantHello tafmakura,
I replaced $user->ID with get_current_user_id in my original code to get the update code. There is no curly ” and ‘ in the code. But, the issue is still there. That is the vendor shop settings page in the frontend is still showing the placeholder values instead of the stored values in the database. See the part of the vendor shop setting page here: http://imgur.com/eZ3tun2
Please, see the updated code in pastebin: http://pastebin.com/Sr48hrnc
Regards,
Stardrive
September 9, 2015 at 5:28 pm #8540stardriveParticipantHello tafmakura,
I have found the cause of the problem. It is the Blog Manager plugin that is conflicting with WC Vendors plugin. (But Blog Manager plugin was not initially among your list of non compatible plugins: https://www.wcvendors.com/knowledgebase/compatible-plugins/)
When I deactivate the Blog Manager plugin, the store settings values stored in the database are displayed in the front-end; but when I activate the Blog Manager plugin, the store settings values stored in the database are no more displayed, the placeholder (default) values are now displayed.
This is what happens when Blog Manager plugin is activated: When Store Settings page is loading, the store settings values stored in the database are initially displayed; but, just a moment before Store Settings page finishes loading, the store settings values stored in the database are no more displayed, the placeholder (default) values are now displayed; and the placeholder (default) values continue showing after Store Settings page finishes loading.
And I need the Blog Manager for my Blog.
Any suggestion on what to do now will be greatly appreciated.
Thank you so much for your patience and kind support. Thank you so much Ben for the same.
Regards,
Stardrive
September 9, 2015 at 8:41 pm #8546tafmakuraParticipantI’m glad you resolved this.
Maybe it’s your theme? If you activate 2015 theme do you get the same issue? If you do then I suggest you seek support from Blog Manager support team because in this case blog manager is conflicting with a WordPress Core function that has nothing to do with WC Vendor directly. The data is saving correctly to the database and when you try to call it from the database using a wordpress function Blog Manager plugin is somehow conflicting with this.
September 10, 2015 at 4:56 am #8563stardriveParticipantThank you.
I have confirmed that Blog Manager is the cause of the issue and i have raised this issue with the Blog Manager support team.
Regards,
Stardrive
-
AuthorPosts
- The forum ‘WC Vendors Free Support’ is closed to new topics and replies.