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;








0















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?










share|improve this question






















  • 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











  • I posted an answer

    – Shoyeb Sheikh
    Mar 9 at 3:51

















0















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?










share|improve this question






















  • 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











  • I posted an answer

    – Shoyeb Sheikh
    Mar 9 at 3:51













0












0








0








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 returns Array

    – 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












  • @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
















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












1 Answer
1






active

oldest

votes


















1














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;






share|improve this answer




















  • 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











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
);



);













draft saved

draft discarded


















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









1














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;






share|improve this answer




















  • 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














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;






share|improve this answer




















  • 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








1







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;






share|improve this answer















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;







share|improve this answer














share|improve this answer



share|improve this answer








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












  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme