Need help with a simple line of php in wordpress

5 replies
Hi, I need a little bit of help changing some code in wordpress wp-login. I don't know php at all, but I've been managing to make minor replacements and changes as needed by finding specific text and changing it. I have the register-plus plugin uploaded and it is customized so that when people get their confirmation email it is from me and the subject is my own custom subject. I want to do the same thing for the two "lost your password" emails, but their is no plugin for these. I've located the portion of the code that needs to be changed and I also know which part of the code has the message body in it to edit. I'm not sure which represents the from field for the email, or the subject field.

I beleive that this line $title = sprintf(__('[%s] Password Reset'), $blogname); is in reference to the subject, but I'm not sure what I can take out to make it right. Right now the subject shows up as [Pro Illusion] Passord Reset, and I want to get rid of the brackets around my blog title and just type my own subject line. I haven't located the from field code at all, so help with both these things is much appreciated. Below are the two codes for the two emails.

Thanks in advance for your help.










wp_set_password($new_pass, $user->ID);
update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
$message .= site_url('wp-login.php', 'login') . "\r\n";

// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

$title = sprintf(__('[%s] Your new password'), $blogname);

$title = apply_filters('password_reset_title', $title);
$message = apply_filters('password_reset_message', $message, $new_pass);

if ( $message && !wp_mail($user->user_email, $title, $message) )
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');

wp_password_change_notification($user);

return true;
}
















The other email is

}
$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
$message .= get_option('siteurl') . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
$message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";

// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

$title = sprintf(__('[%s] Password Reset'), $blogname);

$title = apply_filters('retrieve_password_title', $title);
$message = apply_filters('retrieve_password_message', $message, $key);

if ( $message && !wp_mail($user_email, $title, $message) )
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');

return true;
#line #php #simple #wordpress
  • Profile picture of the author imarketstuff
    Originally Posted by Jacob Kettner View Post

    I beleive that this line = sprintf(__('[%s] Password Reset'), ); is in reference to the subject, but I'm not sure what I can take out to make it right. Right now the subject shows up as [Pro Illusion] Passord Reset, and I want to get rid of the brackets around my blog title and just type my own subject line. I haven't located the from field code at all, so help with both these things is much appreciated. Below are the two codes for the two emails.

    Thanks in advance for your help.
    hey there Jacob

    you are seeing brackets around the blog title because that is apart of the string passed in the sprintf function. remove the brackets around the %s and you'll notice that.

    that code takes the value of ($blogname) and places it in the %s variable used by sprintf, which is surrounded by brackets.

    you can change the subject of the email password by modifying the code like this:

    Code:
      title = 'ADD YOUR OWN PASSWORD RESET TEXT HERE';
    or

    Code:
      title = sprintf(__('YOUR PASSWORD WAS RESET ON - %s'), blogname);
    those are just examples of what you can do..

    because this peace of code is not a plugin, your are "hardcoding" your changes versus setting the email title from the admin interface.

    p.s. i don't have a dollarsign in front of the title variable or blogname because the forum keeps removing the variable when i put one
    Signature
    I MARKET STUFF

    {{ DiscussionBoard.errors[1842334].message }}
  • Profile picture of the author Bruce Hearder
    Have you tried just replacing the contents of the line :

    $title = sprintf(__('[%s] Your new password'), $blogname);

    With what ever text you want to display?

    You could replace the abolve line so that it looks something like:

    $title="Jacob Kettner is a Living Legend";

    Let me now how it goes

    Bruce
    {{ DiscussionBoard.errors[1842341].message }}
  • Profile picture of the author Jacob Kettner
    K this works for changing the subject field. I was almost there. Thanks for your help. What about the from field though? I don't want the email to come from wordpress@proillusion.com I want it to come from my admin email.

    Thanks
    {{ DiscussionBoard.errors[1843655].message }}
  • Profile picture of the author Jacob Kettner
    Got it all working now. Thanks a lot all of you for your help.
    {{ DiscussionBoard.errors[1855491].message }}

Trending Topics