mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- code review for reset password link;
This commit is contained in:
@@ -74,8 +74,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
case 'um_approve_membership':
|
||||
case 'um_reenable':
|
||||
|
||||
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 );
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
||||
|
||||
UM()->user()->approve();
|
||||
break;
|
||||
|
||||
@@ -504,7 +504,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* @param integer $post_id
|
||||
* @return string
|
||||
*/
|
||||
function form_type( $post_id ){
|
||||
function form_type( $post_id ) {
|
||||
$mode = get_post_meta( $post_id, '_um_mode', true );
|
||||
return $mode;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
namespace um\core;
|
||||
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
if ( ! class_exists( 'um\core\Modal' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Class Modal
|
||||
*
|
||||
* @package um\core
|
||||
*/
|
||||
class Modal {
|
||||
@@ -18,17 +21,22 @@ if ( ! class_exists( 'um\core\Modal' ) ) {
|
||||
* Modal constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
add_action('wp_footer', array(&$this, 'load_modal_content'), 9);
|
||||
add_action( 'wp_footer', array(&$this, 'load_modal_content' ), 9 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load modal content
|
||||
*/
|
||||
function load_modal_content(){
|
||||
if ( !is_admin() ) {
|
||||
foreach( glob( um_path . 'templates/modal/*.php' ) as $modal_content) {
|
||||
include_once $modal_content;
|
||||
function load_modal_content() {
|
||||
|
||||
if ( ! is_admin() ) {
|
||||
$modal_templates = glob( um_path . 'templates/modal/*.php' );
|
||||
|
||||
if ( ! empty( $modal_templates ) ) {
|
||||
foreach ( $modal_templates as $modal_content ) {
|
||||
include_once $modal_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace um\core;
|
||||
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
|
||||
|
||||
@@ -671,5 +673,31 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
nocache_headers();
|
||||
setcookie( $name, $value, $expire, $path, COOKIE_DOMAIN, is_ssl(), true );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UM Placeholders for reset password
|
||||
*
|
||||
* @param $placeholders
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function add_placeholder( $placeholders ) {
|
||||
$placeholders[] = '{password_reset_link}';
|
||||
return $placeholders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UM Replace Placeholders for reset password
|
||||
*
|
||||
* @param $replace_placeholders
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function add_replace_placeholder( $replace_placeholders ) {
|
||||
$replace_placeholders[] = um_user( 'password_reset_link' );
|
||||
return $replace_placeholders;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1192,8 +1192,10 @@ 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 );
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
||||
|
||||
UM()->mail()->send( um_user('user_email'), 'resetpw_email' );
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ 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 );
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
||||
|
||||
um_fetch_user( $uid );
|
||||
UM()->user()->approve();
|
||||
|
||||
@@ -614,14 +614,14 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
|
||||
case 'unique_username':
|
||||
|
||||
if ( $args[$key] == '' ) {
|
||||
UM()->form()->add_error($key, __('You must provide a username','ultimate-member') );
|
||||
} else if ( $mode == 'register' && username_exists( sanitize_user( $args[$key] ) ) ) {
|
||||
UM()->form()->add_error($key, __('Your username is already taken','ultimate-member') );
|
||||
} else if ( is_email( $args[$key] ) ) {
|
||||
UM()->form()->add_error($key, __('Username cannot be an email','ultimate-member') );
|
||||
} else if ( ! UM()->validation()->safe_username( $args[$key] ) ) {
|
||||
UM()->form()->add_error($key, __('Your username contains invalid characters','ultimate-member') );
|
||||
if ( $args[ $key ] == '' ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide a username', 'ultimate-member' ) );
|
||||
} elseif ( $mode == 'register' && username_exists( sanitize_user( $args[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'Your username is already taken', 'ultimate-member' ) );
|
||||
} elseif ( is_email( $args[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'Username cannot be an email', 'ultimate-member' ) );
|
||||
} elseif ( ! UM()->validation()->safe_username( $args[$key] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -220,30 +220,6 @@ function um_convert_tags( $content, $args = array(), $with_kses = true ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* UM Placeholders for reset password
|
||||
*
|
||||
* @param $placeholders
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function password_reset_link_tags_patterns( $placeholders ) {
|
||||
$placeholders[] = '{password_reset_link}';
|
||||
return $placeholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* UM Replace Placeholders for reset password
|
||||
*
|
||||
* @param $replace_placeholders
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function password_reset_link_tags_replaces( $replace_placeholders ) {
|
||||
$replace_placeholders[] = um_user( 'password_reset_link' );
|
||||
return $replace_placeholders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @function um_user_ip()
|
||||
|
||||
Reference in New Issue
Block a user