Gibt es eine Möglichkeit, die aktualisierten/hinzugefügten Werte aus dem Profil an den Administrator der Website oder eine andere E-Mail-Adresse zu senden, wenn ein Mitglied/Benutzer seine/ihre Daten aktualisiert?
Kann das der erste Schritt sein?
/* do something when user edits profile */
add_action('personal_options_update', 'notify_admin_on_update');
function notify_admin_on_update(){
// send a mail with the updated values to [email protected]
exit;
}
Was ist die beste Vorgehensweise, um E-Mails aus WordPress heraus zu senden?
du hast den ersten Teil über die Verwendung von personal_options_update
richtig verstanden, aber um auf der sicheren Seite zu sein, füge edit_user_profile_update
hinzu. und was das Versenden von E-Mails in WordPress betrifft, ist der beste Weg, wp_mail zu verwenden.
add_action( 'personal_options_update', 'notify_admin_on_update' );
add_action( 'edit_user_profile_update','notify_admin_on_update');
function notify_admin_on_update(){
global $current_user;
get_currentuserinfo();
if (!current_user_can( 'administrator' )){// avoid sending emails when admin is updating user profiles
$to = '[email protected]';
$subject = 'user updated profile';
$message = "the user : " .$current_user->display_name . " has updated his profile with:\n";
foreach($_POST as $key => $value){
$message .= $key . ": ". $value ."\n";
}
wp_mail( $to, $subject, $message);
}
}