From 002979fadb96c44682181639c77e2ec76aaaeec6 Mon Sep 17 00:00:00 2001 From: andrewshuba Date: Fri, 3 May 2019 16:59:13 +0300 Subject: [PATCH] add filter for replace placeholders in reset password emails --- includes/core/class-user.php | 2 ++ includes/core/um-actions-core.php | 3 +++ includes/um-short-functions.php | 18 +++++++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/includes/core/class-user.php b/includes/core/class-user.php index 22bb1ea5..42c2573c 100644 --- a/includes/core/class-user.php +++ b/includes/core/class-user.php @@ -1192,6 +1192,8 @@ if ( ! class_exists( 'um\core\User' ) ) { function password_reset() { $userdata = get_userdata( um_user('ID') ); get_password_reset_key( $userdata ); + add_filter( 'um_template_tags_patterns_hook', 'password_reset_link_tags_patterns', 10, 1 ); + add_filter( 'um_template_tags_replaces_hook', 'password_reset_link_tags_replaces', 10, 1 ); UM()->mail()->send( um_user('user_email'), 'resetpw_email' ); } diff --git a/includes/core/um-actions-core.php b/includes/core/um-actions-core.php index ba9ea420..79d3eb59 100644 --- a/includes/core/um-actions-core.php +++ b/includes/core/um-actions-core.php @@ -100,6 +100,9 @@ function um_action_request_process() { wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) ); } + add_filter( 'um_template_tags_patterns_hook', 'password_reset_link_tags_patterns', 10, 1 ); + add_filter( 'um_template_tags_replaces_hook', 'password_reset_link_tags_replaces', 10, 1 ); + um_fetch_user( $uid ); UM()->user()->approve(); exit( wp_redirect( UM()->permalinks()->get_current_url( true ) ) ); diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 6415821b..ad78df53 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -60,7 +60,16 @@ function um_is_session_started() { return false; } - +function password_reset_link_tags_patterns( $placeholders ) { + // your code here + $placeholders[] = '{password_reset_link}'; + return $placeholders; +} +function password_reset_link_tags_replaces( $replace_placeholders ) { + // your code here + $replace_placeholders[] = um_user( 'password_reset_link' ); + return $replace_placeholders; +} /** * User clean basename @@ -126,7 +135,7 @@ function um_convert_tags( $content, $args = array(), $with_kses = true ) { '{site_name}', '{site_url}', '{account_activation_link}', - '{password_reset_link}', +// '{password_reset_link}', '{admin_email}', '{user_profile_link}', '{user_account_link}', @@ -170,14 +179,14 @@ function um_convert_tags( $content, $args = array(), $with_kses = true ) { UM()->options()->get( 'site_name' ), get_bloginfo( 'url' ), um_user( 'account_activation_link' ), - um_user( 'password_reset_link' ), +// um_user( 'password_reset_link' ), um_admin_email(), um_user_profile_url(), um_get_core_page( 'account' ), um_user_submitted_registration(), um_get_user_avatar_url(), ); - +// debug_print_backtrace(); /** * UM hook * @@ -220,7 +229,6 @@ function um_convert_tags( $content, $args = array(), $with_kses = true ) { $content = str_replace( '{' . $match . '}', um_user( $strip_key ), $content ); } } - return $content; }