Hi Luo, i need to ask a big favor.
Last time we (you) solved a big issue, but i need to come back to reply #581992 Site access data remains same.
Issue: when i try to get and publish the (user readable) result of that post field, I get only the post value number. You wrote it's normal and some code needs to be changed according website settings.
This issue is so complex (there are custom post fields, views, creds, and extra php) that i'm pretty 'scared' to brake more than i'd solve.
Isn't it possible with some few lines of code to call that post-id value and show it not as a number but as the address it represents? In the views output we used "label" so that in the creds it's normal readable address, but this doesn't work when trying to get this via simple 'insert fields and views' with this code [types usermeta='billing-addresses-nl' user_current='true'][/types] (this code multiplied by the number of regions/views). I can't get to it by using types shortcode either.
Ideally without the need of changing everything what we already set up, just the minimum pain 🙂
Thank you very much!
Dear filip,
To avoid any misunderstanding, please elaborate for the question:
Isn't it possible with some few lines of code to call that post-id value and show it not as a number but as the address it represents?
How and Where do you want to display the address? Could you point out the problem URL and where I should check?
I need to test it in a live website, thanks
hi Luo,
where: on different places in the website, for example on checkout and thank you-page and in a tab of 'my account' page, and some normal pages as well. Also on the admin 'users' pages, but that's a different technique afaik.
How: it could be the same way as on this cred /my-account/my-brands/ (when logged in, field 'billing address'
It could also be split up in the original post fields that were used to create this view (so that i can echo/call address, zip, country, .. separately)
On bottom page /sample-page/ i put that code that gives the ID value; so we like to see corresponding address instead. Since we have so many views for this, i will have to put those codes for each and every view ('nl', 'fr', and so on) because only 1 of them will generate the address, according users' region. I will need to put conditionals to hide the empty ones. Or is there some way to do that with just 1 code, i dont think so?
Thank you!!
There are lots of places and questions you mentioned above, can we handle them one by one,
First the "checkout" page, I tried it in your website:
enlace oculto
I see a input field "BILLING ADDRESS", with placeholder attribute:
"[types field='billing-field-types-address'][/types]"
How can you setup the "placeholder" attribute as "[types field='billing-field-types-address'][/types]"?
Are you using custom PHP codes or theme file? Where can I modify your PHP codes? please provide more details, I need to test and debug it in your website, thanks
Hi Luo,
child theme, functions.php is where you placed custom PHP. I didn't place any extra on top on that, regarding this issue.
Thank you
I just searched text "billing-field-types-address" in your theme file functions.php:
enlace oculto
Found 0 result, so it is not outputted from this file as you mentioned above, and no PHP codes for me to debug.
Then I checked other places you mentioned above, the 'my account' page, I assume it is this one:
enlace oculto
And I see there is a dropdown menu "Billing Address", it is outputted from CRED form "Account details":
enlace oculto
The option value is outputted from below shortcode, it is a ID of "Billing Addresses" post
[wpv-user field="wpcf-billing-addresses-nl"]
The option labels is outputted from Views shortcode:
[wpv-view name="Billing Address View NL"]
Please check above View:
enlace oculto
in section "Loop Output Editor", line 6
Each label is outputted from this code:
"label":"[wpv-post-title] | [types field='billing-fields-types-number'][/types] | [types field='billing-field-types-address'][/types] | [types field='billing-fields-types-postcode'][/types] | [types field='billing-field-types-city'][/types] | [types field='billing-field-types-phone'][/types] | [types field='billing-field-types-vat'][/types]"
So you can simply pass "Billing Addresses" post ID to above shortcodes, then display the label as you want, for example, create a content template "show-the-label-values", with same codes above:
enlace oculto
Then display the label text with below codes:
wpcf-billing-addresses-nl: [wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-nl"]"]
See the result page:
enlace oculto
If you want to display "fr" label, you can just setup the ID attribute as "fr" user field, for example:
wpcf-billing-addresses-fr: [wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-fr"]"]
Please check if it is what you want. thanks
Hi Luo, great work, thanks a lot!
What i didn't know is that i had to make a content template to achieve this; i know now for next time 😉
If you want the following to be split up in a separate topic, i'll do so:
Now how can i achieve the same result (to show the value) in a user field? So that it would be seen in 'admin-users'? I tried with above solution but that didn't work out well.
Kind regards
In addition:
1- i found that the shortcode triggers some unwanted behaviour on most pages: it displays the name of the page in front of the value (checkout, urlxxx/tests/ ) Only on 'thank you' page it doesnt do that.
2- Also, each instance of the shortcode triggers to display the whole php content of that page twice per instance (thank you page)
3- I can't get the conditional to work with this shortcode, to hide the empty values. (url/tests/ ) It shows nothing when it should show result.
Sorry for the trouble!
There are lots of questions in this thread, I am trying to answer them one by one:
Q1) If you want the following to be split up in a separate topic
Please create new thread for the new question, that will help other users to find the answers
Q2) i found that the shortcode triggers some unwanted behaviour on most pages
I assume we are talking about this page in your website:
enlace oculto
If you can point out the problem shortcodes, that will help us to debug this problem.
To debug this problem, it is very simple, you can output the custom user field "wpcf-billing-addresses-nl" value with this:
wpcf-billing-addresses-nl: [wpv-user field="wpcf-billing-addresses-nl"]
It will be able to output a number (post ID), that is setup by the CRED form in your another thread:
https://toolset.com/forums/topic/using-cpt-entries-in-cred-registration-form-select-field/
Then you can pass it as attribute "id" of the content template shortcode:
[wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-nl"]"]
In case the custom user field empty, you can use [wpv-conditional] shortcode to check it, then display the content template shortcode, see below Q4)
Q3) Also, each instance of the shortcode triggers to display the whole php content of that page twice per instance (thank you page)
I suggest you create another thread for this question, describe detail steps for how and where I can see the problem, point out the problem page URL(thank you page), how do you setup the thank you page, with theme or plugin?
Q4) I can't get the conditional to work with this shortcode, to hide the empty values. (url/tests/ ) It shows nothing when it should show result.
Since we checking a custom user field, so you will need to setup the user field shortcode insider "if" attribute, for example:
3.
[wpv-conditional if="!empty([wpv-user field="wpcf-billing-addresses-nl"])"]<strong>Available colours:</strong> [wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-nl"]"][/wpv-conditional]
4.
[wpv-conditional if="!empty([wpv-user field="wpcf-billing-addresses-belux"])"]<strong>Available colours:</strong> [wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-belux"]"][/wpv-conditional]
See the result of tests page:
enlace oculto
More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/