Custom New User Message (function replace_keywords)
-
Hello,
Thank you for great plugin.
I think that I found a problem from your code. At end of functionreplace_keywordsyou have loop which may cause problems.preg_match_all( '/%([^%]+)%/', (string) $message, $keys ); if ( is_array( $keys ) && is_array( $keys[1] ) ) { foreach( $keys[1] as $key ) { $message = str_replace( "%$key%", get_user_meta( $user->ID, $key, TRUE ), $message ); } }If message body, %user_password% or any other field contains ‘%’ characters, this loop will corrupt the email body. Instead of trying to find possible keywords (preg_match_all) from email body I suggest to match only real keywords and real meta. Something like this:
$user_meta = get_user_meta( $user->ID ); foreach ( $user_meta as $key => $value ) { if ( !is_array($value[0]) ) // skip arrays ... ? $message = str_replace( "%".$key."%", $value[0], $message); }Best regards,
petteri
The topic ‘Custom New User Message (function replace_keywords)’ is closed to new replies.