Is there any way to remove html tags from a Field when outputting

We have to use HTML tags to highlight an author name in bold, but we also want to pass the title of the post to a form which generates a PDF Certificate including the title of the post. We don’t want the tags included in the output.

domain.com/form?course_title={Field title} currently outputs domain.com/form?course_title=Arthritis%20pain%20management%20with%20{b}Tamara%20Grubb{/b}

Is there any way to filter out HTML tags in L&L before passing the {Field title} to the URL?

As far as I know, the only sanitize option in L&L right now is the as yet undocumented <Format slug></Format> tag, which will strip out html tags, convert to lowercase and replace spaces with dashes:

http://domain.com/form?course_title={Format slug}{Field title}{/Format}
http://domain.com/form?course_title=arthritis-pain-management-with-tamara-grubb

Can you make that work for your application? Otherwise I think the closest you can get to your current output is by also using a replace and url_query format tag, but your capitalization will be lost:

<Set course_title_param><Format url_query><Format replace="-" with=" "><Format slug><Field title /></Format></Format></Format></Set>
http://domain.com/form?course_title{Get course_title_param}
1 Like

Hi Julia,

★★★★★

Thank you so much. The second option worked perfectly. I am using an all-caps style on the PDF generation, so it doesn’t matter about the capitalisation.

Craig

1 Like

Hi again @julia .

We have another slight issue where occasionally there is a special character in the title (e.g. Ö).

This is being converted to https://caninearthritis.co.uk/member-zone/mz-cpt-certificate-form/?course_title=rehabilitation and physiotherapy in the management of chronic pain with may r

%25c3%25b6

mer bartels

Is there a way to prevent special characters being converted to Unicode?

Hi Craig! Since Julia last responded to this post, there’s been a new remove_html feature added to the Format tag that’s specifically designed to remove HTML tags instead of using the somewhat hacky Format url_query approach that was suggested earlier which is what’s converting things to Unicode. So I imagine if your goal is still just to remove HTML tags, you should be able to do that with something like this:

<Set course_title_param><Format slug><Format remove_html><Field title /></Format></Format></Set>
http://domain.com/form?course_title{Get course_title_param}

Let me know if that works!

Hi Benjamin.

Many thanks for that info. I have successfully used the following to achieve the result I was looking for…

<Set course_title_param><Format remove_html><Format replace="-" with=" "><Format slug><Field title /></Format></Format></Format></Set><a href="https://domain.com/?course_title={Get course_title_param}"></a>

Hope all these Format options will be added to the documentation soon :wink:.

Awesome, glad that worked for you!

Sure thing! The Format remove_html feature was added to the docs when the feature was released last month in version 3.2.1. I wasn’t aware of that Format slug option that Julia mentioned until I read this thread so I’ve gone ahead and added it to the docs as well!

Shameless plug, but if you’re enjoying the features and support that we’re offering with this free plugin and want to help out our team, you might consider adding those stars to a review of the plugin on the WordPress plugin repo :wink: If you’ve already posted a review, thanks a bunch for helping to share the word about the plugin!

Best of luck with L&L!

1 Like

Thank you so much for the assistance. And to the whole team for creating such an amazingly powerful plugin.

I have just added a ★★★★★ review

All the best,
Craig

3 Likes