332
* Filter the email address to send from.
335
* Filters the email address to send from.
336
339
* @param string $from_email Email address to send from.
338
$phpmailer->From = apply_filters( 'wp_mail_from', $from_email );
341
$from_email = apply_filters( 'wp_mail_from', $from_email );
341
* Filter the name to associate with the "from" email address.
344
* Filters the name to associate with the "from" email address.
345
348
* @param string $from_name Name associated with the "from" email address.
347
$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );
350
$from_name = apply_filters( 'wp_mail_from_name', $from_name );
352
$phpmailer->setFrom( $from_email, $from_name );
349
354
// Set destination addresses
350
355
if ( !is_array( $to ) )
351
356
$to = explode( ',', $to );
353
foreach ( (array) $to as $recipient ) {
355
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
356
$recipient_name = '';
357
if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
358
if ( count( $matches ) == 3 ) {
359
$recipient_name = $matches[1];
360
$recipient = $matches[2];
363
$phpmailer->AddAddress( $recipient, $recipient_name);
364
} catch ( phpmailerException $e ) {
369
358
// Set mail's subject and body
370
359
$phpmailer->Subject = $subject;
371
360
$phpmailer->Body = $message;
373
// Add any CC and BCC recipients
374
if ( !empty( $cc ) ) {
375
foreach ( (array) $cc as $recipient ) {
377
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
378
$recipient_name = '';
379
if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
380
if ( count( $matches ) == 3 ) {
381
$recipient_name = $matches[1];
382
$recipient = $matches[2];
385
$phpmailer->AddCc( $recipient, $recipient_name );
386
} catch ( phpmailerException $e ) {
362
// Use appropriate methods for handling addresses, rather than treating them as generic headers
363
$address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' );
365
foreach ( $address_headers as $address_header => $addresses ) {
366
if ( empty( $addresses ) ) {
392
if ( !empty( $bcc ) ) {
393
foreach ( (array) $bcc as $recipient) {
370
foreach ( (array) $addresses as $address ) {
395
372
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
396
373
$recipient_name = '';
397
if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
375
if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) {
398
376
if ( count( $matches ) == 3 ) {
399
377
$recipient_name = $matches[1];
400
$recipient = $matches[2];
378
$address = $matches[2];
403
$phpmailer->AddBcc( $recipient, $recipient_name );
382
switch ( $address_header ) {
384
$phpmailer->addAddress( $address, $recipient_name );
387
$phpmailer->addCc( $address, $recipient_name );
390
$phpmailer->addBcc( $address, $recipient_name );
393
$phpmailer->addReplyTo( $address, $recipient_name );
404
396
} catch ( phpmailerException $e ) {
720
712
$cookie = $user->user_login . '|' . $expiration . '|' . $token . '|' . $hash;
723
* Filter the authentication cookie.
715
* Filters the authentication cookie.
727
719
* @param string $cookie Authentication cookie.
728
720
* @param int $user_id User ID.
729
* @param int $expiration Authentication cookie expiration in seconds.
721
* @param int $expiration The time the cookie expires as a UNIX timestamp.
730
722
* @param string $scheme Cookie scheme used. Accepts 'auth', 'secure_auth', or 'logged_in'.
731
723
* @param string $token User's session token used.
875
867
* @param string $auth_cookie Authentication cookie.
876
* @param int $expire Login grace period in seconds. Default 43,200 seconds, or 12 hours.
877
* @param int $expiration Duration in seconds the authentication cookie should be valid.
878
* Default 1,209,600 seconds, or 14 days.
868
* @param int $expire The time the login grace period expires as a UNIX timestamp.
869
* Default is 12 hours past the cookie's expiration time.
870
* @param int $expiration The time when the authentication cookie expires as a UNIX timestamp.
871
* Default is 14 days from now.
879
872
* @param int $user_id User ID.
880
873
* @param string $scheme Authentication scheme. Values include 'auth', 'secure_auth', or 'logged_in'.
882
875
do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme );
885
* Fires immediately before the secure authentication cookie is set.
878
* Fires immediately before the logged-in authentication cookie is set.
889
882
* @param string $logged_in_cookie The logged-in cookie.
890
* @param int $expire Login grace period in seconds. Default 43,200 seconds, or 12 hours.
891
* @param int $expiration Duration in seconds the authentication cookie should be valid.
892
* Default 1,209,600 seconds, or 14 days.
883
* @param int $expire The time the login grace period expires as a UNIX timestamp.
884
* Default is 12 hours past the cookie's expiration time.
885
* @param int $expiration The time when the logged-in authentication cookie expires as a UNIX timestamp.
886
* Default is 14 days from now.
893
887
* @param int $user_id User ID.
894
888
* @param string $scheme Authentication scheme. Default 'logged_in'.
1669
1676
// send a copy of password change notification to the admin
1670
1677
// but check to see if it's the admin whose password we're changing, and skip this
1671
1678
if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
1672
$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
1679
/* translators: %s: user name */
1680
$message = sprintf( __( 'Password changed for user: %s' ), $user->user_login ) . "\r\n";
1673
1681
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
1674
1682
// we want to reverse this for the plain text arena of emails.
1675
1683
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1676
wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
1684
/* translators: %s: site title */
1685
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Password Changed' ), $blogname ), $message );
1694
1704
* @param int $user_id User ID.
1695
1705
* @param null $deprecated Not used (argument deprecated).
1696
1706
* @param string $notify Optional. Type of notification that should happen. Accepts 'admin' or an empty
1697
* string (admin only), or 'both' (admin and user). Default empty.
1707
* string (admin only), 'user', or 'both' (admin and user). Default empty.
1699
1709
function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
1700
1710
if ( $deprecated !== null ) {
1708
1718
// we want to reverse this for the plain text arena of emails.
1709
1719
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1711
$message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
1712
$message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
1713
$message .= sprintf(__('Email: %s'), $user->user_email) . "\r\n";
1721
if ( 'user' !== $notify ) {
1722
$message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
1723
$message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
1724
$message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
1715
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
1726
@wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
1717
1729
// `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notifcation.
1718
1730
if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {