Issue
I need to send a text email with a link for the user to click. It's a user verification email. The issue I am having is that the URL helper keeps escaping the characters. I feel I have tried the below in every possible combination but to no avail.
echo $this->Url->build([
"controller" => "Users",
"action" => "verify",
"?" => ['email' => $email, 'hash' => $hash]
],[
"escape" => false,
"fullBase" => true
]);
This results in http://www.mydomain.co.uk/users/verify?email=chris%40domain.co.uk&hash=b56a4eea3b495db226888f2f89e7678f where the '@' and '&' charachters are beeing escaped.
Another issue with this is that cake can't access the hash variable but it can the email, ie.
echo $this->request->query('hash') //doesn't print anything
echo $this->request->query('email') //prints email with the @ symbol
Solution
Thanks to Greg Schmidt for pointing out the version inconsistency.
FYI; You can only use the escaping for CakePHP version 3.3.5 and above (As of Nov '16).
I used htmlspecialchars_decode($this->Url->build()) to solve the problem
Answered By - ChrisBull
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.