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.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 30 posts - 1 through 30 (of 30 total)
  • Author
    Posts
  • #8273
    stardrive
    Participant

    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

    #8312
    WC Vendors Support
    Participant

    Then 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. 😉

    #8315
    stardrive
    Participant

    Hello 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’] );
    }
    }

    #8322
    WC Vendors Support
    Participant

    That 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.

    #8324
    stardrive
    Participant

    Hi 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’] );
    }
    }

    #8444
    stardrive
    Participant

    Hi Ben,

    Please, any help on my last request?

    Regards,

    stardrive

    #8445
    WC Vendors Support
    Participant

    Not really, no…… This is deep customization of WC Vendors. It’s up to you to write and fix your own code. =)

    #8446
    stardrive
    Participant

    Hello 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

    #8449
    WC Vendors Support
    Participant

    Unfortunately 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.

    #8452
    stardrive
    Participant

    Hi 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

    #8460
    WC Vendors Support
    Participant

    Hi 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:

    #8462
    stardrive
    Participant

    Hello 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

    #8466
    tafmakura
    Participant

    It’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;
    ?>

    • This reply was modified 7 years, 4 months ago by tafmakura.
    #8468
    tafmakura
    Participant

    http://pastebin.com/embed_iframe.php?i=tzMJZjFC

    • This reply was modified 7 years, 4 months ago by tafmakura.
    #8471
    stardrive
    Participant

    Thank 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’] );
    }
    }

    #8472
    tafmakura
    Participant

    Before 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

    • This reply was modified 7 years, 4 months ago by tafmakura.
    #8474
    stardrive
    Participant

    Pleaser, 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

    #8480
    WC Vendors Support
    Participant

    Thanks @tafmakura for offering your assistance to Stardrive on this. Much appreciated. 🙂

    #8487
    tafmakura
    Participant

    We 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

    http://pastebin.com/raw.php?i=cXZ0amd4

    #8493
    tafmakura
    Participant

    There is a mistake in the code above, the code won’t work, use this instead….

    https://gist.github.com/anonymous/01261f48dbbe28c53840

    • This reply was modified 7 years, 4 months ago by tafmakura.
    • This reply was modified 7 years, 4 months ago by tafmakura.
    #8496
    WC Vendors Support
    Participant

    Line 7 & 8 on the gist need to be single quotes, not curly quotes.

    #8505
    stardrive
    Participant

    Dear 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,
    Stardrive

    #8506
    WC Vendors Support
    Participant

    https://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.

    #8507
    tafmakura
    Participant

    Sorry 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 with get_current_user_idand 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….

    • This reply was modified 7 years, 4 months ago by tafmakura.
    • This reply was modified 7 years, 4 months ago by tafmakura.
    #8510
    stardrive
    Participant

    Thank 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

    #8514
    tafmakura
    Participant

    In 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.

    • This reply was modified 7 years, 4 months ago by tafmakura.
    #8518
    stardrive
    Participant

    Hello 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

    #8540
    stardrive
    Participant

    Hello 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

    #8546
    tafmakura
    Participant

    I’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.

    #8563
    stardrive
    Participant

    Thank 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

Viewing 30 posts - 1 through 30 (of 30 total)
  • The forum ‘WC Vendors Free Support’ is closed to new topics and replies.
This website uses cookies to ensure you get the best experience on our website.