Support

Home Forums Event Espresso Premium Some HTML code getting stripped out when event published

Some HTML code getting stripped out when event published

Posted: August 17, 2020 at 10:10 am


cambridgejbs

August 17, 2020 at 10:10 am

Hi there,

We have just tried adding some embed code from a form creation tool called ClickDimensions (a Microsoft Dynamics plugin). Unfortunately we’re finding that this line of code <div pageID=”100000057″></div> is getting stripped down to just <div></div>, which stops the form embed working. Do you know why this code might be being stripped out, and what we can do to stop this happening?

Thanks! Ruth


Tony

  • Support Staff

August 17, 2020 at 1:54 pm

Hi Ruth,

<div pageID="100000057"></div> isn’t valid, there is no pageID attribute on a div tag which is likely why it’s being stripped out. If you add it to a standard WP page/post using the classic editor those values are also stripped out.

Currently, you would need to switch to ‘Text mode’ on the editor and then paste in that code but if you then switch back to visual mode at all, those values will be stripped out again.

Where exactly are you adding that div?


cambridgejbs

August 18, 2020 at 2:05 am

Hi Tony,

The full code that we embed (in the main part of the page, where you put the event description, and in the Text tab rather than the Visual tab) is this:

<script type=”text/javascript”>var loc = “https://analytics-eu.clickdimensions.com/jbscamacuk-a1tdd/pages/”;</script>
<script type=”text/javascript” src=”https://az551914.vo.msecnd.net/web/v10/CDWidget.js”></script>
<div pageid=”FORM_ID_HERE”></div>

But the last line gets changed to just <div></div> when I switch from the Text tab to the Visual tab then back again…


Tony

  • Support Staff

August 18, 2020 at 8:06 am

But the last line gets changed to just

when I switch from the Text tab to the Visual tab then back again…

That’s expected and happens because pageid isn’t a valid attribute on a div element.

Without custom code you will need to add the above snippet into text mode but as mentioned if you switch back to visual it will strip them out once again.

There are a couple of options to prevent that but both require custom code, you can either:

Hook into TinyMCE and add your own valid attribute of pageid to the div element

or

Hook into the event output and add the embed code via code rather than in the editor, for example, you could add a custom field with the key of ClickDimensions_pageid and then if that value is set on the event add all of the code mentioned above via a hook. If you have different form ID’s you can dynamically add those to the code when it’s output using the value of ClickDimensions_pageid.


cambridgejbs

August 18, 2020 at 10:24 am

Thank you Tony, that’s really helpful, we’ll do that!


Tony

  • Support Staff

August 18, 2020 at 11:14 am

Personally I’d likey use option 2 and if you are looking to do that there are various hooks you can use depending on the specific location you want to add the code.

For example AHEE_event_details_after_the_content, ‘fires’ right after the event description.

The support post ‘Some HTML code getting stripped out when event published’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso