mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Password reset feature and code changes
This commit is contained in:
+4
-4
@@ -46,11 +46,11 @@ class UM_Account {
|
||||
function account(){
|
||||
global $ultimatemember;
|
||||
|
||||
if ( um_is_account_page() && !is_user_logged_in() ) {
|
||||
if ( um_is_core_page('account') && !is_user_logged_in() ) {
|
||||
exit( wp_redirect( home_url() ) );
|
||||
}
|
||||
|
||||
if ( um_is_account_page() ) {
|
||||
if ( um_is_core_page('account') ) {
|
||||
|
||||
$ultimatemember->fields->set_mode = 'account';
|
||||
|
||||
@@ -71,12 +71,12 @@ class UM_Account {
|
||||
|
||||
if ( get_option('permalink_structure') ) {
|
||||
|
||||
$url = trailingslashit( untrailingslashit( um_account_page_url() ) );
|
||||
$url = trailingslashit( untrailingslashit( um_get_core_page('account') ) );
|
||||
$url = $url . $id . '/';
|
||||
|
||||
} else {
|
||||
|
||||
$url = add_query_arg( 'um_tab', $id, um_account_page_url() );
|
||||
$url = add_query_arg( 'um_tab', $id, um_get_core_page('account') );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
exit( wp_redirect( um_account_page_url() ) );
|
||||
exit( wp_redirect( um_get_core_page('account') ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
function um_after_login_submit(){ ?>
|
||||
|
||||
<div class="um-col-alt-b">
|
||||
<a href="<?php echo um_get_core_page('recover'); ?>" class="um-link-alt"><?php _e('Forgot your password?','ultimatemember'); ?></a>
|
||||
<a href="<?php echo um_get_core_page('password-reset'); ?>" class="um-link-alt"><?php _e('Forgot your password?','ultimatemember'); ?></a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/***
|
||||
*** @add a notice to form
|
||||
***/
|
||||
add_action('um_before_form', 'um_add_update_notice', 500 );
|
||||
function um_add_update_notice($args){
|
||||
global $ultimatemember;
|
||||
extract($args);
|
||||
if ( isset( $_REQUEST['updated'] ) && !empty( $_REQUEST['updated'] ) ) {
|
||||
|
||||
switch( $_REQUEST['updated'] ) {
|
||||
|
||||
case 'password_changed':
|
||||
$msg = __('You have successfully changed your password.','ultimatemember');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $msg ) ) {
|
||||
|
||||
echo '<p class="um-notice success">' . $msg . '</p>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
/***
|
||||
*** @process a new request
|
||||
***/
|
||||
add_action('um_reset_password_process_hook','um_reset_password_process_hook');
|
||||
function um_reset_password_process_hook( $args ) {
|
||||
global $ultimatemember;
|
||||
|
||||
$user = $_POST['username_b'];
|
||||
|
||||
if ( !is_email( $user ) ) {
|
||||
$data = get_user_by( 'login', $user );
|
||||
$user_email = $data->user_email;
|
||||
} else {
|
||||
$data = get_user_by( 'email', $user );
|
||||
$user_email = $user;
|
||||
}
|
||||
|
||||
$ultimatemember->password->reset_request['user_id'] = $data->ID;
|
||||
$ultimatemember->password->reset_request['user_email'] = $user_email;
|
||||
|
||||
um_fetch_user( $data->ID );
|
||||
|
||||
$ultimatemember->user->password_reset();
|
||||
|
||||
um_reset_user();
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @process a change request
|
||||
***/
|
||||
add_action('um_change_password_process_hook','um_change_password_process_hook');
|
||||
function um_change_password_process_hook( $args ) {
|
||||
global $ultimatemember;
|
||||
|
||||
wp_set_password( $args['user_password'], $args['user_id'] );
|
||||
|
||||
delete_user_meta( $args['user_id'], 'reset_pass_hash');
|
||||
|
||||
delete_user_meta( $args['user_id'], 'reset_pass_hash_token');
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
wp_logout();
|
||||
}
|
||||
|
||||
exit( wp_redirect( um_get_core_page('login', 'password_changed') ) );
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Error handler: reset password
|
||||
***/
|
||||
add_action('um_reset_password_errors_hook','um_reset_password_errors_hook');
|
||||
function um_reset_password_errors_hook( $args ) {
|
||||
global $ultimatemember;
|
||||
|
||||
if ( $_POST[ $ultimatemember->honeypot ] != '' )
|
||||
wp_die('Hello, spam bot!');
|
||||
|
||||
$form_timestamp = trim($_POST['timestamp']);
|
||||
$live_timestamp = time();
|
||||
|
||||
if ( $form_timestamp == '' )
|
||||
wp_die( __('Hello, spam bot!') );
|
||||
|
||||
if ( $live_timestamp - $form_timestamp < 3 )
|
||||
wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
|
||||
|
||||
if ( strlen(trim( $_POST['username_b'] ) ) == 0 ) {
|
||||
$ultimatemember->form->add_error('username_b', __('Please provide your username or email','ultimatemember') );
|
||||
}
|
||||
|
||||
$user = $_POST['username_b'];
|
||||
|
||||
if ( ( !is_email( $user ) && !username_exists( $user ) ) || ( is_email( $user ) && !email_exists( $user ) ) ) {
|
||||
$ultimatemember->form->add_error('username_b', __(' We can\'t find an account registered with that address or username ','ultimatemember') );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Error handler: changing password
|
||||
***/
|
||||
add_action('um_change_password_errors_hook','um_change_password_errors_hook');
|
||||
function um_change_password_errors_hook( $args ) {
|
||||
global $ultimatemember;
|
||||
|
||||
if ( $_POST[ $ultimatemember->honeypot ] != '' )
|
||||
wp_die('Hello, spam bot!');
|
||||
|
||||
$form_timestamp = trim($_POST['timestamp']);
|
||||
$live_timestamp = time();
|
||||
|
||||
if ( $form_timestamp == '' )
|
||||
wp_die( __('Hello, spam bot!') );
|
||||
|
||||
if ( $live_timestamp - $form_timestamp < 3 )
|
||||
wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
|
||||
|
||||
if ( !$args['user_password'] ) {
|
||||
$ultimatemember->form->add_error('user_password', 'You must enter a new password');
|
||||
}
|
||||
|
||||
if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
|
||||
$ultimatemember->form->add_error('user_password', __('Your password must contain at least 8 characters') );
|
||||
}
|
||||
|
||||
if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) {
|
||||
$ultimatemember->form->add_error('user_password', __('Your password must contain less than 30 characters') );
|
||||
}
|
||||
|
||||
if ( !$ultimatemember->validation->strong_pass( $args['user_password'] ) ) {
|
||||
$ultimatemember->form->add_error('user_password', 'Your password must contain at least one capital letter and one number');
|
||||
}
|
||||
|
||||
if ( !$args['confirm_user_password'] ) {
|
||||
$ultimatemember->form->add_error('confirm_user_password', 'You must confirm your new password');
|
||||
}
|
||||
|
||||
if ( $args['user_password'] != $args['confirm_user_password'] ) {
|
||||
$ultimatemember->form->add_error('confirm_user_password', 'Your passwords do not match');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @hidden fields
|
||||
***/
|
||||
add_action('um_change_password_page_hidden_fields','um_change_password_page_hidden_fields');
|
||||
function um_change_password_page_hidden_fields( $args ) {
|
||||
|
||||
?>
|
||||
|
||||
<input type="hidden" name="_um_password_change" id="_um_password_change" value="1" />
|
||||
|
||||
<input type="hidden" name="user_id" id="user_id" value="<?php echo $args['user_id']; ?>" />
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @hidden fields
|
||||
***/
|
||||
add_action('um_reset_password_page_hidden_fields','um_reset_password_page_hidden_fields');
|
||||
function um_reset_password_page_hidden_fields( $args ) {
|
||||
|
||||
?>
|
||||
|
||||
<input type="hidden" name="_um_password_reset" id="_um_password_reset" value="1" />
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @form content
|
||||
***/
|
||||
add_action('um_reset_password_form', 'um_reset_password_form');
|
||||
function um_reset_password_form() {
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
$fields = $ultimatemember->builtin->get_specific_fields('password_reset_text,username_b'); ?>
|
||||
|
||||
<?php $output = null;
|
||||
foreach( $fields as $key => $data ) {
|
||||
$output .= $ultimatemember->fields->edit_field( $key, $data );
|
||||
}echo $output; ?>
|
||||
|
||||
<div class="um-col-alt um-col-alt-b">
|
||||
|
||||
<div class="um-center"><input type="submit" value="<?php _e('Reset my password','ultimatemember'); ?>" class="um-button" /></div>
|
||||
|
||||
<div class="um-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @change password form
|
||||
***/
|
||||
add_action('um_change_password_form', 'um_change_password_form');
|
||||
function um_change_password_form() {
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
$fields = $ultimatemember->builtin->get_specific_fields('user_password'); ?>
|
||||
|
||||
<?php $output = null;
|
||||
foreach( $fields as $key => $data ) {
|
||||
$output .= $ultimatemember->fields->edit_field( $key, $data );
|
||||
}echo $output; ?>
|
||||
|
||||
<div class="um-col-alt um-col-alt-b">
|
||||
|
||||
<div class="um-center"><input type="submit" value="<?php _e('Change my password','ultimatemember'); ?>" class="um-button" /></div>
|
||||
|
||||
<div class="um-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
if ( um_is_user_page_uri() && um_get_requested_user() ) {
|
||||
if ( um_is_core_page('user') && um_get_requested_user() ) {
|
||||
|
||||
um_fetch_user( um_get_requested_user() );
|
||||
|
||||
|
||||
+23
-1
@@ -336,7 +336,7 @@ class UM_Builtin {
|
||||
),
|
||||
|
||||
'block' => array(
|
||||
'name' => 'Text Block',
|
||||
'name' => 'Content Block',
|
||||
'col1' => array('_title'),
|
||||
'col2' => array('_public','_roles'),
|
||||
'col_full' => array('_content'),
|
||||
@@ -700,6 +700,28 @@ class UM_Builtin {
|
||||
'icon' => 'um-icon-device-mobile',
|
||||
),
|
||||
|
||||
// for use in password reset page
|
||||
|
||||
'password_reset_text' => array(
|
||||
'title' => 'Password Reset',
|
||||
'type' => 'block',
|
||||
'content' => '<div style="text-align:center">To reset your password, please enter your email address or username below</div>',
|
||||
'private_use' => true,
|
||||
),
|
||||
|
||||
'username_b' => array(
|
||||
'title' => 'Username or E-mail',
|
||||
'metakey' => 'username_b',
|
||||
'type' => 'text',
|
||||
'placeholder' => __('Enter your username or email','ultimatemember'),
|
||||
'required' => 1,
|
||||
'public' => 1,
|
||||
'editable' => 0,
|
||||
'private_use' => true,
|
||||
),
|
||||
|
||||
// for use in account page
|
||||
|
||||
'profile_privacy' => array(
|
||||
'title' => 'Profile Privacy',
|
||||
'metakey' => 'profile_privacy',
|
||||
|
||||
+7
-3
@@ -290,7 +290,7 @@ class UM_Fields {
|
||||
// normal state
|
||||
if ( isset($ultimatemember->form->post_form[$key]) ) {
|
||||
|
||||
if ( strstr( $key, 'user_pass' ) ) return '';
|
||||
if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) return '';
|
||||
|
||||
return $ultimatemember->form->post_form[$key];
|
||||
|
||||
@@ -735,7 +735,7 @@ class UM_Fields {
|
||||
|
||||
} else {
|
||||
|
||||
if ( $this->set_mode == 'account' && um_is_account_page() ) {
|
||||
if ( $this->set_mode == 'account' && um_is_core_page('account') ) {
|
||||
|
||||
$key = 'current_' . $original_key;
|
||||
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="'.$key.'">';
|
||||
@@ -768,10 +768,14 @@ class UM_Fields {
|
||||
|
||||
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="'.$key.'">';
|
||||
|
||||
if ( $this->set_mode == 'account' && um_is_account_page() ) {
|
||||
if ( $this->set_mode == 'account' && um_is_core_page('account') || $this->set_mode == 'password' && um_is_core_page('password-reset') ) {
|
||||
|
||||
$output .= $this->field_label( 'New Password', $key, $data);
|
||||
|
||||
} else if ( isset( $data['label'] ) ) {
|
||||
|
||||
$output .= $this->field_label($label, $key, $data);
|
||||
|
||||
}
|
||||
|
||||
$output .= '<div class="um-field-area">';
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
$profile_title = um_get_option('profile_title');
|
||||
|
||||
if ( um_is_user_page_uri() && um_get_requested_user() ) {
|
||||
if ( um_is_core_page('user') && um_get_requested_user() ) {
|
||||
|
||||
um_fetch_user( um_get_requested_user() );
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
return $title;
|
||||
|
||||
if ( $id == $ultimatemember->permalinks->core['user'] ) {
|
||||
if ( um_is_user_page_uri() && um_get_requested_user() ) {
|
||||
if ( um_is_core_page('user') && um_get_requested_user() ) {
|
||||
$title = um_get_display_name( um_get_requested_user() );
|
||||
} else if ( um_is_user_page_uri() && is_user_logged_in() ) {
|
||||
} else if ( um_is_core_page('user') && is_user_logged_in() ) {
|
||||
$title = um_get_display_name( get_current_user_id() );
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -67,8 +67,7 @@ class UM_Form {
|
||||
$this->post_form['submitted'] = $this->post_form;
|
||||
|
||||
$this->post_form = array_merge( $this->form_data, $this->post_form );
|
||||
|
||||
/*
|
||||
|
||||
if ( $_POST[ $ultimatemember->honeypot ] != '' )
|
||||
wp_die('Hello, spam bot!');
|
||||
|
||||
@@ -81,10 +80,9 @@ class UM_Form {
|
||||
wp_die( __('Hello, spam bot!') );
|
||||
|
||||
if ( $live_timestamp - $form_timestamp < 5 )
|
||||
wp_die( __('Whoa, slow down! You’re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
|
||||
wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/* Continue based on form mode - pre-validation */
|
||||
|
||||
|
||||
+3
-1
@@ -12,7 +12,8 @@ class UM_Logout {
|
||||
*** @Logout via logout page
|
||||
***/
|
||||
function logout_page() {
|
||||
if ( um_is_logout_page() ) {
|
||||
|
||||
if ( um_is_core_page('logout') ) {
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
|
||||
@@ -32,6 +33,7 @@ class UM_Logout {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,6 +38,7 @@ class UM_Mail {
|
||||
'{display_name}',
|
||||
'{site_name}',
|
||||
'{account_activation_link}',
|
||||
'{password_reset_link}',
|
||||
'{admin_email}',
|
||||
'{user_profile_link}',
|
||||
);
|
||||
@@ -48,6 +49,7 @@ class UM_Mail {
|
||||
um_user('display_name'),
|
||||
um_get_option('site_name'),
|
||||
um_user('account_activation_link'),
|
||||
um_user('password_reset_link'),
|
||||
um_admin_email(),
|
||||
um_user_profile_url(),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
class UM_Password {
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_shortcode('ultimatemember_password', array(&$this, 'ultimatemember_password'), 1);
|
||||
|
||||
add_action('template_redirect', array(&$this, 'password_reset'), 10001 );
|
||||
|
||||
add_action('template_redirect', array(&$this, 'form_init'), 10002);
|
||||
|
||||
add_action('init', array(&$this, 'listen_to_password_reset_uri'), 1);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @a listener to password reset uri
|
||||
***/
|
||||
function listen_to_password_reset_uri() {
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
if ( isset($_REQUEST['act']) && $_REQUEST['act'] == 'reset_password' && isset($_REQUEST['hash']) && strlen($_REQUEST['hash']) == 30 &&
|
||||
isset($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id']) ) {
|
||||
|
||||
um_fetch_user( $_REQUEST['user_id'] );
|
||||
|
||||
if ( $_REQUEST['hash'] != um_user('reset_pass_hash') ) wp_die( __('This is not a valid hash, or it has expired.','ultimatemember') );
|
||||
|
||||
$ultimatemember->user->profile['reset_pass_hash_token'] = time();
|
||||
$ultimatemember->user->update_usermeta_info('reset_pass_hash_token');
|
||||
|
||||
$this->change_password = true;
|
||||
|
||||
um_reset_user();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @reset url
|
||||
***/
|
||||
function reset_url(){
|
||||
global $ultimatemember;
|
||||
|
||||
if ( !um_user('reset_pass_hash') ) return false;
|
||||
|
||||
$url = add_query_arg( 'act', 'reset_password', um_get_core_page('password-reset') );
|
||||
$url = add_query_arg( 'hash', um_user('reset_pass_hash'), $url );
|
||||
$url = add_query_arg( 'user_id', um_user('ID'), $url );
|
||||
|
||||
return $url;
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @we are on password reset page
|
||||
***/
|
||||
function password_reset(){
|
||||
global $ultimatemember;
|
||||
|
||||
if ( um_is_core_page('password-reset') ) {
|
||||
|
||||
$ultimatemember->fields->set_mode = 'password';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @password page form
|
||||
***/
|
||||
function form_init() {
|
||||
global $ultimatemember;
|
||||
|
||||
if ( um_requesting_password_reset() ) {
|
||||
|
||||
$ultimatemember->form->post_form = $_POST;
|
||||
|
||||
do_action('um_reset_password_errors_hook', $ultimatemember->form->post_form );
|
||||
|
||||
if ( !isset($ultimatemember->form->errors) ) {
|
||||
|
||||
do_action('um_reset_password_process_hook', $ultimatemember->form->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( um_requesting_password_change() ) {
|
||||
|
||||
$ultimatemember->form->post_form = $_POST;
|
||||
|
||||
do_action('um_change_password_errors_hook', $ultimatemember->form->post_form );
|
||||
|
||||
if ( !isset($ultimatemember->form->errors) ) {
|
||||
|
||||
do_action('um_change_password_process_hook', $ultimatemember->form->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Add class based on shortcode
|
||||
***/
|
||||
function get_class( $mode ){
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
$classes = 'um-'.$mode;
|
||||
|
||||
if ( is_admin() ) {
|
||||
$classes .= ' um-in-admin';
|
||||
}
|
||||
|
||||
if ( $ultimatemember->fields->editing == true ) {
|
||||
$classes .= ' um-editing';
|
||||
}
|
||||
|
||||
if ( $ultimatemember->fields->viewing == true ) {
|
||||
$classes .= ' um-viewing';
|
||||
}
|
||||
|
||||
$classes = apply_filters('um_form_official_classes__hook', $classes);
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Shortcode
|
||||
***/
|
||||
function ultimatemember_password( $args = array() ) {
|
||||
return $this->load( $args );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Load a module with global function
|
||||
***/
|
||||
function load( $args ) {
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
ob_start();
|
||||
|
||||
$defaults = array(
|
||||
'template' => 'password-reset',
|
||||
'mode' => 'password',
|
||||
'form_id' => 'um_password_id',
|
||||
'max_width' => '450px',
|
||||
'align' => 'center',
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
if ( isset( $args['use_globals'] ) && $args['use_globals'] == 1 ) {
|
||||
$args = array_merge( $args, $this->get_css_args( $args ) );
|
||||
} else {
|
||||
$args = array_merge( $this->get_css_args( $args ), $args );
|
||||
}
|
||||
|
||||
$args = apply_filters('um_reset_password_shortcode_args_filter', $args);
|
||||
|
||||
if ( isset( $this->change_password ) ) {
|
||||
|
||||
$args['user_id'] = $_REQUEST['user_id'];
|
||||
$args['template'] = 'password-change';
|
||||
|
||||
}
|
||||
|
||||
extract( $args, EXTR_SKIP );
|
||||
|
||||
do_action("um_pre_{$mode}_shortcode", $args);
|
||||
|
||||
do_action("um_before_form_is_loaded", $args);
|
||||
|
||||
do_action("um_before_{$mode}_form_is_loaded", $args);
|
||||
|
||||
do_action("um_before_{$template}_form_is_loaded", $args);
|
||||
|
||||
$this->template_load( $template, $args );
|
||||
|
||||
if ( !is_admin() && !defined( 'DOING_AJAX' ) ) {
|
||||
$this->dynamic_css( $args );
|
||||
}
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Get dynamic css args
|
||||
***/
|
||||
function get_css_args( $args ) {
|
||||
$arr = um_styling_defaults( $args['mode'] );
|
||||
$arr = array_merge( $arr, array( 'form_id' => $args['form_id'], 'mode' => $args['mode'] ) );
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Load dynamic css
|
||||
***/
|
||||
function dynamic_css( $args=array() ) {
|
||||
extract($args);
|
||||
$global = um_path . 'assets/dynamic_css/dynamic_global.php';
|
||||
$file = um_path . 'assets/dynamic_css/dynamic_'.$mode.'.php';
|
||||
include $global;
|
||||
if ( file_exists( $file ) )
|
||||
include $file;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Loads a template file
|
||||
***/
|
||||
function template_load( $template, $args=array() ) {
|
||||
global $ultimatemember;
|
||||
extract($args);
|
||||
$file = um_path . 'templates/'. $template . '.php';
|
||||
if ( file_exists( $file ) ) include $file;
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,7 @@ class UM_Permalinks {
|
||||
$ultimatemember->user->approve();
|
||||
|
||||
um_reset_user();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,6 +124,7 @@ class UM_Permalinks {
|
||||
***/
|
||||
function profile_url() {
|
||||
global $ultimatemember;
|
||||
|
||||
$profile_url = $this->core['user'];
|
||||
$profile_url = get_permalink($profile_url);
|
||||
|
||||
|
||||
+4
-4
@@ -59,14 +59,14 @@ class UM_Rewrite {
|
||||
function locate_user_profile() {
|
||||
global $post, $ultimatemember;
|
||||
|
||||
if ( um_queried_user() && um_is_user_page_uri() ) {
|
||||
if ( um_queried_user() && um_is_core_page('user') ) {
|
||||
|
||||
if ( um_get_option('permalink_base') == 'user_login' ) {
|
||||
$user_id = username_exists( um_queried_user() );
|
||||
if ( $user_id ) {
|
||||
um_set_requested_user( $user_id );
|
||||
} else {
|
||||
exit( wp_redirect( um_user_page_uri() ) );
|
||||
exit( wp_redirect( um_get_core_page('user') ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class UM_Rewrite {
|
||||
if ( $user_id ) {
|
||||
um_set_requested_user( $user_id );
|
||||
} else {
|
||||
exit( wp_redirect( um_user_page_uri() ) );
|
||||
exit( wp_redirect( um_get_core_page('user') ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class UM_Rewrite {
|
||||
if ( $user_id ) {
|
||||
um_set_requested_user( $user_id );
|
||||
} else {
|
||||
exit( wp_redirect( um_user_page_uri() ) );
|
||||
exit( wp_redirect( um_get_core_page('user') ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+42
-75
@@ -3,13 +3,27 @@
|
||||
/***
|
||||
*** @Get core page url
|
||||
***/
|
||||
function um_get_core_page( $slug ) {
|
||||
function um_get_core_page( $slug, $updated = false) {
|
||||
global $ultimatemember;
|
||||
if ( $ultimatemember->permalinks->core[ $slug ] )
|
||||
return get_permalink( $ultimatemember->permalinks->core[ $slug ] );
|
||||
$url = get_permalink( $ultimatemember->permalinks->core[ $slug ] );
|
||||
if ( $updated ) {
|
||||
$url = add_query_arg( 'updated', $updated, $url );
|
||||
}
|
||||
return $url;
|
||||
return '';
|
||||
}
|
||||
|
||||
/***
|
||||
*** @boolean check if we are on a core page or not
|
||||
***/
|
||||
function um_is_core_page( $page ) {
|
||||
global $post, $ultimatemember;
|
||||
if ( isset($post->ID) && $post->ID == $ultimatemember->permalinks->core[ $page ] )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Check value of queried search in text input
|
||||
***/
|
||||
@@ -67,57 +81,35 @@
|
||||
return '';
|
||||
}
|
||||
|
||||
/***
|
||||
*** @check if a legitimate password reset request is in action
|
||||
***/
|
||||
function um_requesting_password_reset() {
|
||||
global $post, $ultimatemember;
|
||||
if ( um_is_core_page('password-reset') && isset( $_POST['_um_password_reset'] ) == 1 )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @check if a legitimate password change request is in action
|
||||
***/
|
||||
function um_requesting_password_change() {
|
||||
global $post, $ultimatemember;
|
||||
if ( um_is_core_page('password-reset') && isset( $_POST['_um_password_change'] ) == 1 )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @boolean for account page editing
|
||||
***/
|
||||
function um_submitting_account_page() {
|
||||
if ( um_is_account_page() && isset($_POST['_um_account']) == 1 && is_user_logged_in() )
|
||||
if ( um_is_core_page('account') && isset($_POST['_um_account']) == 1 && is_user_logged_in() )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @if we're on account page
|
||||
***/
|
||||
function um_is_account_page() {
|
||||
global $post, $ultimatemember;
|
||||
if ( isset($post->ID) && $post->ID == $ultimatemember->permalinks->core['account'] )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @account page URI
|
||||
***/
|
||||
function um_account_page_url(){
|
||||
global $ultimatemember;
|
||||
return get_permalink( $ultimatemember->permalinks->core['account'] );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @if we're on logout page
|
||||
***/
|
||||
function um_is_logout_page() {
|
||||
global $post, $ultimatemember;
|
||||
if ( isset($post->ID) && $post->ID == $ultimatemember->permalinks->core['logout'] )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @show logout page url
|
||||
***/
|
||||
function um_logout_page( $redirect_to = false ) {
|
||||
global $ultimatemember;
|
||||
if ( isset( $ultimatemember->permalinks->core['logout'] ) && is_user_logged_in() )
|
||||
$link = get_permalink( $ultimatemember->permalinks->core['logout'] );
|
||||
if ( $redirect_to ) {
|
||||
$link = add_query_arg( 'redirect_to', $redirect_to, $link );
|
||||
}
|
||||
return $link;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @get a user's display name
|
||||
***/
|
||||
@@ -161,39 +153,10 @@
|
||||
***/
|
||||
function um_is_my_profile() {
|
||||
if ( !is_user_logged_in() ) return false;
|
||||
if ( um_is_user_page_uri() && get_current_user_id() == um_get_requested_user() ) return true;
|
||||
if ( um_is_core_page('user') && get_current_user_id() == um_get_requested_user() ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @The UM's profile page URI
|
||||
***/
|
||||
function um_user_page_uri(){
|
||||
global $ultimatemember;
|
||||
return get_permalink( $ultimatemember->permalinks->core['user'] );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @checks whether we're on UM profile page
|
||||
***/
|
||||
function um_is_user_page_uri() {
|
||||
global $post, $ultimatemember;
|
||||
if ( isset($post->ID) && $post->ID == $ultimatemember->permalinks->core['user'] )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @user's profile ID
|
||||
***/
|
||||
function um_user_page_id() {
|
||||
global $post, $ultimatemember;
|
||||
if ( isset( $ultimatemember->permalinks->core['user'] ) ) {
|
||||
return $ultimatemember->permalinks->core['user'];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/***
|
||||
*** @gets the queried user
|
||||
***/
|
||||
@@ -543,6 +506,10 @@
|
||||
return $array;
|
||||
break;
|
||||
|
||||
case 'password_reset_link':
|
||||
return $ultimatemember->password->reset_url();
|
||||
break;
|
||||
|
||||
case 'account_activation_link':
|
||||
return $ultimatemember->permalinks->activate_url();
|
||||
break;
|
||||
|
||||
@@ -207,6 +207,17 @@ class UM_User {
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Set user's hash for password reset
|
||||
***/
|
||||
function password_reset_hash(){
|
||||
global $ultimatemember;
|
||||
|
||||
$this->profile['reset_pass_hash'] = $ultimatemember->validation->generate(30);
|
||||
$this->update_usermeta_info('reset_pass_hash');
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Set user's hash
|
||||
***/
|
||||
@@ -222,6 +233,15 @@ class UM_User {
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @password reset email
|
||||
***/
|
||||
function password_reset(){
|
||||
global $ultimatemember;
|
||||
$this->password_reset_hash();
|
||||
$ultimatemember->mail->send( um_user('user_email'), 'resetpw_email' );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @approves a user
|
||||
***/
|
||||
|
||||
Reference in New Issue
Block a user