Skip Navigation

[Gelöst] A field that contains a script will not display unless you are logged in

This support ticket is created vor 5 Jahren, 3 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

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

Zuletzt aktualisiert von Tim Elliott vor 5 Jahren, 3 Monaten.

Assistiert von: Nigel.

Author
Artikel
#1316983

I have a custom multi-line field that contains a script for a certain post:

<script type="text/javascript" src="<em><u>versteckter Link</u></em>"></script>

I'm displaying it in a content template using:

[types field='casino-cta-script' output='raw'][/types]

When I'm logged in to admin and I view the post on the frontend the banner is displayed as expected.
When I'm not logged in and I view the post the banner is not displayed. There is no code being shown.

If I change the field value to some text it does display on the frontend, it's just the code that doesn't get rendered.
I've also tried it with a single line field and the same thing happens.

Link to a page where the issue can be seen: versteckter Link
Just below the "Ratings" section is a grey bar where the banner should appear.

#1317061

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi Tim

It seems to be a problem with the script you are calling rather than with the Types custom field.

I set up a local test to confirm that script tags work okay inside a multiline field whether logged in or not (with a simple text alert) and it did.

So, following your example, I added a slightly more complex case where I was src-ing an external script, but I got the same result.

I linked to some random library available on a CDN and used it and it worked whether logged-in as an admin or visiting the page as a guest.

Concretely, this is what I added to my multiline text field:

<script type="text/javascript" src="<em><u>versteckter Link</u></em>"></script>

<script type="text/javascript">

adblockDetect( function(adblockDetected) {

    if (adblockDetected) {
        console.log('Ad blocker is detected');
    } else {
        console.log('Ad blocker is not detected');
    }

    }, {
    testInterval: 40,
    testRuns: 5
    }
);

</script>

The first script tag pulls in an external script, the second script tag uses it, sending messages to the console.

And it worked, as I say, in either scenario.

So the problem appears to be particular to your script.

I suggest you try to reproduce my test to confirm the same. If you get different results then we'd need to try testing for conflicts with other plugins or your theme, etc.

#1317089

Hi Nigel

Thanks for testing. I think it's nothing to do with Toolset now, so sorry to have taken up your time. I believe it's the caching plugin causing the problem.

Thanks for your help.
Tim

#1317101

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Sure, no problem.

If that is the case then please feel free to close.

#1317103

My issue is resolved now. Thank you!