Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Hashing a commenter's email address
Hi. I’m stuck. Again.
I’d like to hash the contents of <txp:comment_email>
. Before I hash it, I’d like to trim any whitespace and convert to lower case. With that in mind, I’m using a trim
, then a strtolower
, and finally an md5
. When these are combined into what I thought would work:
<txp:php>echo md5( strtolower( trim( "<txp:comment_email />" ) ) );</txp:php>
…I do get an MD5 sum, but it’s the same for every comment: ba9245e23ffeed4cc895e1a6b12a78e5. Using <txp:comment_email>
inside the comment does return the correct value, but smushing it down to an MD5 is not working for me.
Any pointers as to what I’m doing wrong?
Thank you in advance.
Offline
Re: Hashing a commenter's email address
You can call almost any Txp tag as a function in PHP. Most tags require one argument (the tag attributes), which you can simply pass as an empty array if you don’t need any attributes. comment_email
doesn’t, however. (Depending on the function you may also need to run parse()
on it.)
<txp:php>echo md5( strtolower( trim( comment_email( ) ) ) );</txp:php>
Code is topiary
Offline
Re: Hashing a commenter's email address
That makes perfect sense, jsoo – thank you very much!
Offline
Pages: 1