set directory transient to 1 week. add notify to profile save hook

This commit is contained in:
Evan Mullins 2019-04-04 09:14:04 -06:00
parent bd5742d0a2
commit 7862f803a7
2 changed files with 14 additions and 2 deletions

View file

@ -238,7 +238,7 @@ function wasmo_update_user( $post_id ) {
// update last_save timestamp for this user
$user_id = intval( substr( $post_id, 5 ) );
update_user_meta( $user_id, 'last_save', time() );
// clear directory transients
delete_transient( 'directory-1' );
delete_transient( 'directory-0' );
@ -248,6 +248,17 @@ function wasmo_update_user( $post_id ) {
wasmo_update_user_question_count();
}
// notify email
$notify_mail_to = get_bloginfo( 'admin_email' );
$notify_mail_subject = 'User Profile Updated - ' . $user_id;
$user_info = get_userdata( $user_id );
$user_loginname = $user_info->user_login;
$user_nicename = $user_info->user_nicename;
$headers = 'From: '. $user_infop->user_email . "\r\n" .
'Reply-To: ' . $notify_mail_to;
$notify_mail_message = $user_nicename . '(' . $user_loginname . ') has just updated thier user profile:' . get_author_posts_url( $user_id );
wp_mail( $to, $subject, $message, $headers );
}
add_action( 'acf/save_post', 'wasmo_update_user', 5 );

View file

@ -3,6 +3,7 @@
// define transient name - taxid + user state.
$transient_name = 'directory-' . is_user_logged_in();
$transient_exp = 24 * HOUR_IN_SECONDS;
// debug
// if ( current_user_can('administrator') && WP_DEBUG ) {
// $transient_name = time();
@ -53,6 +54,6 @@ if ( false === ( $the_directory = get_transient( $transient_name ) ) ) {
$the_directory .= '</div>';
$the_directory .= '</section>';
set_transient( $transient_name, $the_directory, 24 * HOUR_IN_SECONDS );
set_transient( $transient_name, $the_directory, $transient_exp );
}
echo $the_directory;