Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 03-08-2010, 10:55 PM   #1
Active Warrior
War Room Member
 
Join Date: Apr 2008
Location: , , .
Posts: 50
Thanks: 4
Thanked 1 Time in 1 Post
Default Need help with a simple line of php in wordpress

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;

Jacob Kettner is offline   Reply With Quote
Old 03-08-2010, 11:55 PM   #2
HyperActive Warrior
War Room Member
 
Join Date: Dec 2009
Location: Costa Rica
Posts: 172
Thanks: 74
Thanked 44 Times in 42 Posts
Default Re: Need help with a simple line of php in wordpress

Quote:
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

imarketstuff is offline   Reply With Quote
Old 03-08-2010, 11:56 PM   #3
Advanced Warrior
War Room Member
 
Bruce Hearder's Avatar
 
Join Date: May 2004
Location: Perth, Australia.
Posts: 717
Thanks: 4
Thanked 182 Times in 138 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Bruce Hearder
Default Re: Need help with a simple line of php in wordpress

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

-----------------
Get Your Backlinks indexed quicker at BackLinks2RSS

Create Full Text Feeds from Partial RSS Feeds at FeedExpander.com. See the WarriorForum post about it here
Bruce Hearder is offline   Reply With Quote
Old 03-09-2010, 08:54 AM   #4
Active Warrior
War Room Member
 
Join Date: Apr 2008
Location: , , .
Posts: 50
Thanks: 4
Thanked 1 Time in 1 Post
Default Re: Need help with a simple line of php in wordpress

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

Jacob Kettner is offline   Reply With Quote
Old 03-09-2010, 11:08 AM   #5
HyperActive Warrior
War Room Member
 
Join Date: Dec 2009
Location: Costa Rica
Posts: 172
Thanks: 74
Thanked 44 Times in 42 Posts
Default Re: Need help with a simple line of php in wordpress

Quote:
Originally Posted by Jacob Kettner View Post
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
hey there Jacob

someone has written a wp-plugin for this:

WordPress Plugin - Change WP eMail From Details | Tips and Tricks

try it out, hope it works for you!

imarketstuff is offline   Reply With Quote
Old 03-11-2010, 11:06 PM   #6
Active Warrior
War Room Member
 
Join Date: Apr 2008
Location: , , .
Posts: 50
Thanks: 4
Thanked 1 Time in 1 Post
Default Re: Need help with a simple line of php in wordpress

Got it all working now. Thanks a lot all of you for your help.

Jacob Kettner is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
line, php, simple, wordpress

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 09:04 AM.