If any one can help me urgently I would be most grateful.
I am trying to get this function below to work but I get a fatal error when the user tries to submit...
It is on a multisite install.
Please live demo here [[LINK href="http://motocomdigital.co.uk/wp-login.php?action=lostpassword"]]http://motocomdigital.co.uk/wp-login.php?action=lostpassword[[/LINK]]
Please just submit <strong>admin</strong> to test error...
Please see my code...
add_filter ("wp_mail_content_type", "my_awesome_mail_content_type");
function my_awesome_mail_content_type() {
return "text/html";
}
add_filter ("wp_mail_from", "my_awesome_mail_from");
function my_awesome_mail_from() {
return "[email protected]";
}
add_filter ("wp_mail_from_name", "my_awesome_mail_from_name");
function my_awesome_email_from_name() {
return "My Site Network";
}
add_filter ("retrieve_password_title", "my_awesome_retrieve_password_title");
function my_awesome_retrieve_password_title() {
return "Create Password";
}
add_filter ("retrieve_password_message", "my_awesome_retrieve_password_message");
function my_awesome_retrieve_password_message($content, $key) {
global $wpdb;
$user_login = $wpdb->get_var("SELECT user_login FROM $wpdb-<users WHERE user_activation_key = '$key'");
ob_start();
$email_subject = imp_retrieve_password_title();
include("email_header.php");
?>
<p>
Hello <?php echo $user_name; ?>,
</p>
<p>
You have requested to create a password via the <a href="<?php echo wp_login_url("url") ?>" target="_blank" title="www.mysite.com">www.mysite.com</a>
</p>
<p>
<a href="<?php echo wp_login_url("url") ?>?action=rp&key=<?php echo $key ?>&login=<?php echo $user_login ?>" title="">To create your own password, please click this link.</a>
</a>
<p>
<strong>If you did not request a new password, please ignore this email.</strong>
</p>
<?php
include("email_footer.php");
$message = ob_get_contents();
ob_end_clean();
return $message;
}
Can anyone please help me - thanks you!
Francisco Javier Carazo Gil answers:
Try to set the filter to accept 2 args:
add_filter ("retrieve_password_message", "my_awesome_retrieve_password_message", 10, 2 );
Josh Cranwell comments:
I've changed that line too...
Which got rid of notice thanks, but now with Dbranes change I'm getting this error.
Fatal error: Call to undefined function imp_retrieve_password_title() in /home/sites/motocomdigital.co.uk/www/wp-content/themes/twentytwelve/functions.php on line 538
[[LINK href="http://motocomdigital.co.uk/wp-login.php?action=lostpassword"]]http://motocomdigital.co.uk/wp-login.php?action=lostpassword[[/LINK]]
Dbranes answers:
this line looks strange
user_login = $wpdb->get_var("SELECT user_login FROM $wpdb-<users WHERE user_activation_key = '$key'");
i.e. the arrow is pointing in the wrong direction:
$wpdb-<users
<strong>Edit:</strong>
You could try this, with the <strong>wpdb->prepare()</strong> function and curly brackets <strong>{$wpdb->users}</strong> :
$user_login = $wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->users} WHERE user_activation_key = '%s'",$key));
Josh Cranwell comments:
I've changed that line too...
$user_login = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_activation_key = '$key'");
OK now I've got this...
Fatal error: Call to undefined function imp_retrieve_password_title() in /home/sites/motocomdigital.co.uk/www/wp-content/themes/twentytwelve/functions.php on line 538
Dbranes comments:
maybe you want to use
my_awesome_retrieve_password_title()
instead of
imp_retrieve_password_title()
Josh Cranwell comments:
YEEEEESSS!!! you the man.
Thanks. Can you help me with one more thing and I will add another $10.
Where is says...
Hello <?php echo $user_name; ?>,
How can get the First name of the user and echo it here?
Thanks
Dbranes comments:
ok great,
sure, you can try
$user = get_user_by('login', $user_login);
echo 'Hello ' . $user->first_name . ' ' . $user->last_name;
Dbranes comments:
and without the echo:
<?php $user = get_user_by('login', $user_login);?>
<p>
Hello <?php echo user->first_name; ?> <?php echo user->last_name; ?>,
</p>
Josh Cranwell comments:
Perfect Perfect!!
Thank you very much.