Wordpress/Elementor/PHP Code Widget: PHP code is not execute and everything after “=>” renders as...
I want to execute some PHP code in an WordPress Elementor template with the PHP Code Widget. Everything works fine as long as I am logged in.
If I log out, the code is not executed and everything after "=>" shows as plain text.
So e.g. the code
<?php
echo 'before';
$someArray = ['foo' => 'bar'];
echo 'after';
?>
<b>some HTML</b>
would result in the following string:
'bar']; echo 'after'; ?>
The HTML after this is fine.
If I place the same code in another widget outside of Elementor (e.g. the footer of the theme), everything also works fine.
I am the admin of this single WordPress installation.
Has anyone an idea, how to stop this behaviour?
php wordpress widget elementor
add a comment |
I want to execute some PHP code in an WordPress Elementor template with the PHP Code Widget. Everything works fine as long as I am logged in.
If I log out, the code is not executed and everything after "=>" shows as plain text.
So e.g. the code
<?php
echo 'before';
$someArray = ['foo' => 'bar'];
echo 'after';
?>
<b>some HTML</b>
would result in the following string:
'bar']; echo 'after'; ?>
The HTML after this is fine.
If I place the same code in another widget outside of Elementor (e.g. the footer of the theme), everything also works fine.
I am the admin of this single WordPress installation.
Has anyone an idea, how to stop this behaviour?
php wordpress widget elementor
so when you logged-in as admin then this code runs? yes? what output it is giving at that time?
– Alive to Die
Nov 14 '17 at 4:22
Yes. The code also runs, when I am logged in with an account, that has only the author role. The output is what I would expect:beforeafter
– cgdannie
Nov 14 '17 at 18:16
add a comment |
I want to execute some PHP code in an WordPress Elementor template with the PHP Code Widget. Everything works fine as long as I am logged in.
If I log out, the code is not executed and everything after "=>" shows as plain text.
So e.g. the code
<?php
echo 'before';
$someArray = ['foo' => 'bar'];
echo 'after';
?>
<b>some HTML</b>
would result in the following string:
'bar']; echo 'after'; ?>
The HTML after this is fine.
If I place the same code in another widget outside of Elementor (e.g. the footer of the theme), everything also works fine.
I am the admin of this single WordPress installation.
Has anyone an idea, how to stop this behaviour?
php wordpress widget elementor
I want to execute some PHP code in an WordPress Elementor template with the PHP Code Widget. Everything works fine as long as I am logged in.
If I log out, the code is not executed and everything after "=>" shows as plain text.
So e.g. the code
<?php
echo 'before';
$someArray = ['foo' => 'bar'];
echo 'after';
?>
<b>some HTML</b>
would result in the following string:
'bar']; echo 'after'; ?>
The HTML after this is fine.
If I place the same code in another widget outside of Elementor (e.g. the footer of the theme), everything also works fine.
I am the admin of this single WordPress installation.
Has anyone an idea, how to stop this behaviour?
php wordpress widget elementor
php wordpress widget elementor
asked Nov 14 '17 at 4:18
cgdanniecgdannie
848
848
so when you logged-in as admin then this code runs? yes? what output it is giving at that time?
– Alive to Die
Nov 14 '17 at 4:22
Yes. The code also runs, when I am logged in with an account, that has only the author role. The output is what I would expect:beforeafter
– cgdannie
Nov 14 '17 at 18:16
add a comment |
so when you logged-in as admin then this code runs? yes? what output it is giving at that time?
– Alive to Die
Nov 14 '17 at 4:22
Yes. The code also runs, when I am logged in with an account, that has only the author role. The output is what I would expect:beforeafter
– cgdannie
Nov 14 '17 at 18:16
so when you logged-in as admin then this code runs? yes? what output it is giving at that time?
– Alive to Die
Nov 14 '17 at 4:22
so when you logged-in as admin then this code runs? yes? what output it is giving at that time?
– Alive to Die
Nov 14 '17 at 4:22
Yes. The code also runs, when I am logged in with an account, that has only the author role. The output is what I would expect:
beforeafter
– cgdannie
Nov 14 '17 at 18:16
Yes. The code also runs, when I am logged in with an account, that has only the author role. The output is what I would expect:
beforeafter
– cgdannie
Nov 14 '17 at 18:16
add a comment |
2 Answers
2
active
oldest
votes
Only users with the unfiltered_html role will be allowed to insert unfiltered HTML. This includes PHP code, so users without admin or editor permissions will not be able to use this to execute code, even if they have widget editing permissions.
taken form https://wordpress.org/plugins/php-code-widget/
Thanks, but I wrote "I am the admin of this single WordPress installation."
– cgdannie
Sep 12 '18 at 9:06
add a comment |
I could reproduce the problem.
One way to work around this: use an Elementor HTML widget with an iframe
in it and write the PHP code in the src-file as a complete HTML page.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47277596%2fwordpress-elementor-php-code-widget-php-code-is-not-execute-and-everything-afte%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Only users with the unfiltered_html role will be allowed to insert unfiltered HTML. This includes PHP code, so users without admin or editor permissions will not be able to use this to execute code, even if they have widget editing permissions.
taken form https://wordpress.org/plugins/php-code-widget/
Thanks, but I wrote "I am the admin of this single WordPress installation."
– cgdannie
Sep 12 '18 at 9:06
add a comment |
Only users with the unfiltered_html role will be allowed to insert unfiltered HTML. This includes PHP code, so users without admin or editor permissions will not be able to use this to execute code, even if they have widget editing permissions.
taken form https://wordpress.org/plugins/php-code-widget/
Thanks, but I wrote "I am the admin of this single WordPress installation."
– cgdannie
Sep 12 '18 at 9:06
add a comment |
Only users with the unfiltered_html role will be allowed to insert unfiltered HTML. This includes PHP code, so users without admin or editor permissions will not be able to use this to execute code, even if they have widget editing permissions.
taken form https://wordpress.org/plugins/php-code-widget/
Only users with the unfiltered_html role will be allowed to insert unfiltered HTML. This includes PHP code, so users without admin or editor permissions will not be able to use this to execute code, even if they have widget editing permissions.
taken form https://wordpress.org/plugins/php-code-widget/
answered Sep 11 '18 at 1:45
Louis van WykLouis van Wyk
1
1
Thanks, but I wrote "I am the admin of this single WordPress installation."
– cgdannie
Sep 12 '18 at 9:06
add a comment |
Thanks, but I wrote "I am the admin of this single WordPress installation."
– cgdannie
Sep 12 '18 at 9:06
Thanks, but I wrote "I am the admin of this single WordPress installation."
– cgdannie
Sep 12 '18 at 9:06
Thanks, but I wrote "I am the admin of this single WordPress installation."
– cgdannie
Sep 12 '18 at 9:06
add a comment |
I could reproduce the problem.
One way to work around this: use an Elementor HTML widget with an iframe
in it and write the PHP code in the src-file as a complete HTML page.
add a comment |
I could reproduce the problem.
One way to work around this: use an Elementor HTML widget with an iframe
in it and write the PHP code in the src-file as a complete HTML page.
add a comment |
I could reproduce the problem.
One way to work around this: use an Elementor HTML widget with an iframe
in it and write the PHP code in the src-file as a complete HTML page.
I could reproduce the problem.
One way to work around this: use an Elementor HTML widget with an iframe
in it and write the PHP code in the src-file as a complete HTML page.
edited Jan 1 at 20:20


trincot
128k1688123
128k1688123
answered Jan 1 at 19:31


Paul_CPaul_C
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47277596%2fwordpress-elementor-php-code-widget-php-code-is-not-execute-and-everything-afte%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
so when you logged-in as admin then this code runs? yes? what output it is giving at that time?
– Alive to Die
Nov 14 '17 at 4:22
Yes. The code also runs, when I am logged in with an account, that has only the author role. The output is what I would expect:
beforeafter
– cgdannie
Nov 14 '17 at 18:16