Function is not not working inside PHP mail bodyHow can I prevent SQL injection in PHP?How do JavaScript closures work?What's the difference between a method and a function?var functionName = function() vs function functionName() PHP: Delete an element from an arraystartsWith() and endsWith() functions in PHPSet a default parameter value for a JavaScript functionReference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?
What would happen to a modern skyscraper if it rains micro blackholes?
Can I make popcorn with any corn?
Theorems that impeded progress
What do you call a Matrix-like slowdown and camera movement effect?
I probably found a bug with the sudo apt install function
Representing power series as a function - what to do with the constant after integration?
Why is the design of haulage companies so “special”?
How to get the available space of $HOME as a variable in shell scripting?
How is it possible for user to changed after storage was encrypted? (on OS X, Android)
Is it possible to make sharp wind that can cut stuff from afar?
What are these boxed doors outside store fronts in New York?
Motorized valve interfering with button?
Compute hash value according to multiplication method
Is the month field really deprecated?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
Underlining section titles
How is it possible to have an ability score that is less than 3?
How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?
A function which translates a sentence to title-case
Email Account under attack (really) - anything I can do?
How is this relation reflexive?
Possibly bubble sort algorithm
Function is not not working inside PHP mail body
How can I prevent SQL injection in PHP?How do JavaScript closures work?What's the difference between a method and a function?var functionName = function() vs function functionName() PHP: Delete an element from an arraystartsWith() and endsWith() functions in PHPSet a default parameter value for a JavaScript functionReference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm using this to send a basic email:
// Email details
$name = 'Davo';
$recipient = 'info@davo.com';
$from = 'sender@example.com'
$subject = 'Testing';
// All plugins
function the_plugins()
$the_plugs = get_option('active_plugins');
foreach($the_plugs as $key => $value)
$string = explode('/',$value); print $string[0] . '<br />';
// Message
$body = '<p>Hello' . $name . ',</p>';
$body .= '<p>Your website has these plugins:</p>';
$body .= the_plugins();
$body .= '<p>Have a nice day.</p>';
$headers[] = 'Content-type:text/html;charset=UTF-8';
$headers[] = 'From' . $name. ' <' . $from . '>';
$headers[] = 'Reply-To: ' . $from;
$headers[] = 'MIME-Version: 1.0';
wp_mail($recipient, $subject, $body, $headers);
The only things that does not work is the_plugins()
function does not show anything in the email that arrives. Instead it's just empty in the line where I expect to see the list of plugins, and looks like this:
Hello Davo,
Your website has these plugins:
Have a nice day.
FYI the_plugins()
function works. I am able to echo the_plugins(); exit;
right after the function and it returns a list of the plugins, so the function itself is not the problem.
Any suggestions on how to get around this?
php wordpress function email
add a comment |
I'm using this to send a basic email:
// Email details
$name = 'Davo';
$recipient = 'info@davo.com';
$from = 'sender@example.com'
$subject = 'Testing';
// All plugins
function the_plugins()
$the_plugs = get_option('active_plugins');
foreach($the_plugs as $key => $value)
$string = explode('/',$value); print $string[0] . '<br />';
// Message
$body = '<p>Hello' . $name . ',</p>';
$body .= '<p>Your website has these plugins:</p>';
$body .= the_plugins();
$body .= '<p>Have a nice day.</p>';
$headers[] = 'Content-type:text/html;charset=UTF-8';
$headers[] = 'From' . $name. ' <' . $from . '>';
$headers[] = 'Reply-To: ' . $from;
$headers[] = 'MIME-Version: 1.0';
wp_mail($recipient, $subject, $body, $headers);
The only things that does not work is the_plugins()
function does not show anything in the email that arrives. Instead it's just empty in the line where I expect to see the list of plugins, and looks like this:
Hello Davo,
Your website has these plugins:
Have a nice day.
FYI the_plugins()
function works. I am able to echo the_plugins(); exit;
right after the function and it returns a list of the plugins, so the function itself is not the problem.
Any suggestions on how to get around this?
php wordpress function email
Return string from function. And remove print statement.
– Shoyeb Sheikh
Mar 9 at 3:44
@ShoyebSheikh do you mean like this:return $string = explode('/',$value); print $string[0] . '<br />';
If I do that, it returnsArray
– user3256143
Mar 9 at 3:47
I posted an answer
– Shoyeb Sheikh
Mar 9 at 3:51
add a comment |
I'm using this to send a basic email:
// Email details
$name = 'Davo';
$recipient = 'info@davo.com';
$from = 'sender@example.com'
$subject = 'Testing';
// All plugins
function the_plugins()
$the_plugs = get_option('active_plugins');
foreach($the_plugs as $key => $value)
$string = explode('/',$value); print $string[0] . '<br />';
// Message
$body = '<p>Hello' . $name . ',</p>';
$body .= '<p>Your website has these plugins:</p>';
$body .= the_plugins();
$body .= '<p>Have a nice day.</p>';
$headers[] = 'Content-type:text/html;charset=UTF-8';
$headers[] = 'From' . $name. ' <' . $from . '>';
$headers[] = 'Reply-To: ' . $from;
$headers[] = 'MIME-Version: 1.0';
wp_mail($recipient, $subject, $body, $headers);
The only things that does not work is the_plugins()
function does not show anything in the email that arrives. Instead it's just empty in the line where I expect to see the list of plugins, and looks like this:
Hello Davo,
Your website has these plugins:
Have a nice day.
FYI the_plugins()
function works. I am able to echo the_plugins(); exit;
right after the function and it returns a list of the plugins, so the function itself is not the problem.
Any suggestions on how to get around this?
php wordpress function email
I'm using this to send a basic email:
// Email details
$name = 'Davo';
$recipient = 'info@davo.com';
$from = 'sender@example.com'
$subject = 'Testing';
// All plugins
function the_plugins()
$the_plugs = get_option('active_plugins');
foreach($the_plugs as $key => $value)
$string = explode('/',$value); print $string[0] . '<br />';
// Message
$body = '<p>Hello' . $name . ',</p>';
$body .= '<p>Your website has these plugins:</p>';
$body .= the_plugins();
$body .= '<p>Have a nice day.</p>';
$headers[] = 'Content-type:text/html;charset=UTF-8';
$headers[] = 'From' . $name. ' <' . $from . '>';
$headers[] = 'Reply-To: ' . $from;
$headers[] = 'MIME-Version: 1.0';
wp_mail($recipient, $subject, $body, $headers);
The only things that does not work is the_plugins()
function does not show anything in the email that arrives. Instead it's just empty in the line where I expect to see the list of plugins, and looks like this:
Hello Davo,
Your website has these plugins:
Have a nice day.
FYI the_plugins()
function works. I am able to echo the_plugins(); exit;
right after the function and it returns a list of the plugins, so the function itself is not the problem.
Any suggestions on how to get around this?
php wordpress function email
php wordpress function email
asked Mar 9 at 3:41
user3256143user3256143
304227
304227
Return string from function. And remove print statement.
– Shoyeb Sheikh
Mar 9 at 3:44
@ShoyebSheikh do you mean like this:return $string = explode('/',$value); print $string[0] . '<br />';
If I do that, it returnsArray
– user3256143
Mar 9 at 3:47
I posted an answer
– Shoyeb Sheikh
Mar 9 at 3:51
add a comment |
Return string from function. And remove print statement.
– Shoyeb Sheikh
Mar 9 at 3:44
@ShoyebSheikh do you mean like this:return $string = explode('/',$value); print $string[0] . '<br />';
If I do that, it returnsArray
– user3256143
Mar 9 at 3:47
I posted an answer
– Shoyeb Sheikh
Mar 9 at 3:51
Return string from function. And remove print statement.
– Shoyeb Sheikh
Mar 9 at 3:44
Return string from function. And remove print statement.
– Shoyeb Sheikh
Mar 9 at 3:44
@ShoyebSheikh do you mean like this:
return $string = explode('/',$value); print $string[0] . '<br />';
If I do that, it returns Array
– user3256143
Mar 9 at 3:47
@ShoyebSheikh do you mean like this:
return $string = explode('/',$value); print $string[0] . '<br />';
If I do that, it returns Array
– user3256143
Mar 9 at 3:47
I posted an answer
– Shoyeb Sheikh
Mar 9 at 3:51
I posted an answer
– Shoyeb Sheikh
Mar 9 at 3:51
add a comment |
1 Answer
1
active
oldest
votes
Try this,
function the_plugins()
$the_plugs = get_option('active_plugins');
$plugins = '';
foreach($the_plugs as $key => $value)
$string = explode('/',$value);
$plugins .= $string[0] . '<br />';
return $plugins;
1
That did it (missing a semicolon though) - thanks!
– user3256143
Mar 9 at 3:52
Yeah I posted it from mobile lol
– Shoyeb Sheikh
Mar 9 at 3:53
Mark this as answer thank you.
– Shoyeb Sheikh
Mar 9 at 3:54
Roger that - done.
– user3256143
Mar 9 at 3:57
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%2f55073768%2ffunction-is-not-not-working-inside-php-mail-body%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this,
function the_plugins()
$the_plugs = get_option('active_plugins');
$plugins = '';
foreach($the_plugs as $key => $value)
$string = explode('/',$value);
$plugins .= $string[0] . '<br />';
return $plugins;
1
That did it (missing a semicolon though) - thanks!
– user3256143
Mar 9 at 3:52
Yeah I posted it from mobile lol
– Shoyeb Sheikh
Mar 9 at 3:53
Mark this as answer thank you.
– Shoyeb Sheikh
Mar 9 at 3:54
Roger that - done.
– user3256143
Mar 9 at 3:57
add a comment |
Try this,
function the_plugins()
$the_plugs = get_option('active_plugins');
$plugins = '';
foreach($the_plugs as $key => $value)
$string = explode('/',$value);
$plugins .= $string[0] . '<br />';
return $plugins;
1
That did it (missing a semicolon though) - thanks!
– user3256143
Mar 9 at 3:52
Yeah I posted it from mobile lol
– Shoyeb Sheikh
Mar 9 at 3:53
Mark this as answer thank you.
– Shoyeb Sheikh
Mar 9 at 3:54
Roger that - done.
– user3256143
Mar 9 at 3:57
add a comment |
Try this,
function the_plugins()
$the_plugs = get_option('active_plugins');
$plugins = '';
foreach($the_plugs as $key => $value)
$string = explode('/',$value);
$plugins .= $string[0] . '<br />';
return $plugins;
Try this,
function the_plugins()
$the_plugs = get_option('active_plugins');
$plugins = '';
foreach($the_plugs as $key => $value)
$string = explode('/',$value);
$plugins .= $string[0] . '<br />';
return $plugins;
edited Mar 9 at 3:53
answered Mar 9 at 3:49
Shoyeb SheikhShoyeb Sheikh
607211
607211
1
That did it (missing a semicolon though) - thanks!
– user3256143
Mar 9 at 3:52
Yeah I posted it from mobile lol
– Shoyeb Sheikh
Mar 9 at 3:53
Mark this as answer thank you.
– Shoyeb Sheikh
Mar 9 at 3:54
Roger that - done.
– user3256143
Mar 9 at 3:57
add a comment |
1
That did it (missing a semicolon though) - thanks!
– user3256143
Mar 9 at 3:52
Yeah I posted it from mobile lol
– Shoyeb Sheikh
Mar 9 at 3:53
Mark this as answer thank you.
– Shoyeb Sheikh
Mar 9 at 3:54
Roger that - done.
– user3256143
Mar 9 at 3:57
1
1
That did it (missing a semicolon though) - thanks!
– user3256143
Mar 9 at 3:52
That did it (missing a semicolon though) - thanks!
– user3256143
Mar 9 at 3:52
Yeah I posted it from mobile lol
– Shoyeb Sheikh
Mar 9 at 3:53
Yeah I posted it from mobile lol
– Shoyeb Sheikh
Mar 9 at 3:53
Mark this as answer thank you.
– Shoyeb Sheikh
Mar 9 at 3:54
Mark this as answer thank you.
– Shoyeb Sheikh
Mar 9 at 3:54
Roger that - done.
– user3256143
Mar 9 at 3:57
Roger that - done.
– user3256143
Mar 9 at 3:57
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%2f55073768%2ffunction-is-not-not-working-inside-php-mail-body%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
Return string from function. And remove print statement.
– Shoyeb Sheikh
Mar 9 at 3:44
@ShoyebSheikh do you mean like this:
return $string = explode('/',$value); print $string[0] . '<br />';
If I do that, it returnsArray
– user3256143
Mar 9 at 3:47
I posted an answer
– Shoyeb Sheikh
Mar 9 at 3:51