Tell us what you are trying to do?
There is a "county" in the user Information field.
1. I want to use this value as a filter when making add form
2. and making a page with view block.
I registered snippet to receive the value.
$current_user = wp_get_current_user();
$branch_name = $current_user->county;
How can I use variable values?
There is no appeal unless it is an example image attached.
I just need to know how to get the variable value
What is the link to your site?
hidden link
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
I'm not sure what kind of field you have - is it single field? If yes:
with the cred_field shortcode you should add the attribute value="[your-shortcode]" where [your-shortcode] should return the value of $branch_name.
I created shortcode and activated it with a snippet
Can I use the shortcode as shown in the image?
*******
add_shortcode ( 'branch_value' , 'user_county_value' );
function user_county_value() {
$current_user = wp_get_current_user();
$branch_name = $current_user->county
return $branch_name;
}
******
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
For the form's screenshot yet, but please make sure your shortcode does return the correct value before you use anywhere.
For the view's, you should not use it as filter, but set your view filter to filter by shortcode attribute and then use the shortcode as view's shortcode attribute value.
More info:
=> https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes
Also, please register the shortcode for security reasons:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/how-to-create-a-custom-shortcode/#using-the-custom-shortcode
My issue is resolved now.
Thank you for your help.
I'll give it a try.