I have this function:
function generic_notify($subject = "notify triggered", $message = "<p>Generic notification</p>", $to = "pavel.janicek@mydomain.mydomain"){
EDD()->emails->send( $to, $subject, $message );
}
In some cases, I am completely fine to just call generic_notify();
and know that some function was called, because the above will send me mail.
In other cases, I would like to just change message, or just subject or send it to other email.
If I wanted to just change the message, is it possible? And if yes, how?
You can't but if I were you just put a condition inside that function
function generic_notify($subject = null, $message = null, $to = null){
// your default value
$defaultSubject = "notify triggered";
$defaultMessage = "<p>Generic notification</p>";
$defaultTo = "pavel.janicek@mydomain.mydomain";
$to = (!empty($to)) ? $to : $defaultTo;
$subject = (!empty($subject)) ? $subject : $defaultSubject;
$message = (!empty($message)) ? $message : $defaultMessage;
echo "Subject: ".$subject ."<br>";
echo "Message: ".$message ."<br>";
echo "TO: ".$to."<br>";
}
// if you want not to change all the default parameter just leave blank
generic_notify();
// if you want to change the default parameter just put a value that is not null on it
generic_notify(null, '<p>Change Message</p>', null);