Skip Navigation

[Resolved] Cannot display < (less than symbol) from text field

This support ticket is created 2 years, 7 months ago. 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 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by keithP-6 2 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#2520953

I am trying to: output the value of a text field with a "less than" symbol in it

I expected to see: the text value as inputted

Instead, I got: it cuts off the display at the less than symbol and treats it like a new HTML element.

#2522345

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

After reviewing your debug information, I can see that you are running with outdated Toolset plugins. We always recommend running your site with latest stable Toolset plugin version. Could you please try to update all Toolset plugins to its latest official release version.

*** Please make a FULL BACKUP of your database and website.***
You can download latest Toolset plugins from your account's download page:
=> https://toolset.com/account/downloads/

Once all of your Toolset plugins are updated, Can you please share where exactly it happens and on what URL I can see the issue on what URL and what is your expected results.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2523381
Screenshot-2022-12-27-171311.png
Screenshot-2022-12-27-170900.png

Hey Minesh!

Thanks for getting back to me! This site is designed to store sensitive information so if we don't need to grant access that would be preferable. But I will if we must.

I have updated the Toolset software (it was only one minor version off), and I should note that the site is running on a WordPress multi-site installation.

In short, the problem is as I've described and you should be able to reproduce this pretty easily. I enter a value into a simple text field and the value has a less-than symbol in it. On the front end, it cuts off the value at the less-than symbols and treats the less-than symbol and the remainder of the value as an HTML tag. Please see the attachments provided.

#2523591

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I understand and indeed I'm able to reproduce the issue and happy to share the workaround.

You can use filter to escape the field value: wpcf_fields_slug_{your_custom_field_slug}_value_display
Where:
- Replace {your_custom_field_slug} with your custom field slug.

For example- if you have custom field namely "price", then the filter name should be: wpcf_fields_slug_price_value_display

Could you please try to add the following filter to "Custom Code" section or to your current theme's functions.php file:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

add_filter('wpcf_fields_slug_price_value_display', 'func_filter_to_escape_html_field_value');
function func_filter_to_escape_html_field_value($value) {
	return esc_html($value);
}

Where:
- Replace price with your original field slug.

#2523879

Perfect Minesh! Worked like a charm! My issue is resolved now. Thank you! Might be good to somehow make this an option built into Toolset.