I am trying to put an if statement when calling a class, but the operator -> produces a problem I cant figure out. So calling the class like:
$email = WP_Mail::init()
->to('myemail@hotmail.com')
->subject('This is an automated message pleas do not reply')
->template(plugin_dir_path( __DIR__ ) .'email-templates/email.php', [
'name' => 'Anthony Budd',
'email' => 'test@test.com',
'skills' => [
'PHP',
'AWS',
]
]);
if (site_url() === 'mysite'){
->send();
}else {
->render();
echo $email;
}
normally it would look like:
$email = WP_Mail::init()
->to('john.doe@gmail.com')
->template(get_template_directory() .'/emails/demo.php', [
'name' => 'Anthony Budd',
'location' => 'London',
'skills' => [
'PHP',
'AWS',
]
])
->send();
this above produces an error due to the operator, how can I return "->render()" or "->send()". I want to display the data if on my dev computer but when I push the code to me server it needs to send the email.
Aucun commentaire:
Enregistrer un commentaire