Navigation überspringen

[Gelöst] There is a "county" in the user Information field. I want to use this value

This support ticket is created vor 4 years, 12 months. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von chelhwanS vor 4 years, 11 months.

Assistiert von: Minesh.

Author
Artikel
#2084259
34.png
33.png

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?
versteckter Link

#2084381

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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.

#2085269
42.png
41.png

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;
}

******

#2088193

Minesh
Unterstützer

Sprachen: Englisch (English )

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

#2089203

My issue is resolved now.
Thank you for your help.
I'll give it a try.