mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- add meta to user
This commit is contained in:
@@ -334,8 +334,8 @@ if ( ! class_exists( 'um\Config' ) ) {
|
||||
'subject' => 'Welcome to {site_name}!',
|
||||
'body' => 'Hi {display_name},<br /><br />' .
|
||||
'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
|
||||
'To login please visit the following url:<br /><br />' .
|
||||
'{login_url} <br /><br />' .
|
||||
'{action_title}:<br /><br />' .
|
||||
'{action_url} <br /><br />' .
|
||||
'Your account e-mail: {email} <br />' .
|
||||
'Your account username: {username} <br /><br />' .
|
||||
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
||||
|
||||
@@ -423,9 +423,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->mail(), 'add_placeholder' ) );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->mail(), 'add_replace_placeholder' ) );
|
||||
if ( array_key_exists( 'generated_pass', $args ) && 1 === absint( $args['generated_pass'] ) ) {
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->mail(), 'add_replace_placeholder_set_password' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters email notification subject.
|
||||
@@ -624,9 +621,10 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
$placeholders[] = '{admin_email}';
|
||||
$placeholders[] = '{submitted_registration}';
|
||||
$placeholders[] = '{login_url}';
|
||||
$placeholders[] = '{login_button}';
|
||||
$placeholders[] = '{password}';
|
||||
$placeholders[] = '{account_activation_link}';
|
||||
$placeholders[] = '{action_url}';
|
||||
$placeholders[] = '{action_title}';
|
||||
return $placeholders;
|
||||
}
|
||||
|
||||
@@ -643,25 +641,14 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
$replace_placeholders[] = um_admin_email();
|
||||
$replace_placeholders[] = um_user_submitted_registration_formatted();
|
||||
$replace_placeholders[] = um_get_core_page( 'login' );
|
||||
$replace_placeholders[] = esc_html__( 'Login to our site', 'ultimate-member' );
|
||||
$replace_placeholders[] = esc_html__( 'Your set password', 'ultimate-member' );
|
||||
$replace_placeholders[] = um_user( 'account_activation_link' );
|
||||
return $replace_placeholders;
|
||||
}
|
||||
|
||||
|
||||
public function add_replace_placeholder_set_password( $replace_placeholders ) {
|
||||
$key = array_search( um_get_core_page( 'login' ), $replace_placeholders, true );
|
||||
if ( false !== $key ) {
|
||||
$url = UM()->password()->reset_url();
|
||||
$replace_placeholders[ $key ] = add_query_arg( array( 'set_pass' => 'new_user' ), $url );
|
||||
}
|
||||
|
||||
$button = esc_html__( 'Login to our site', 'ultimate-member' );
|
||||
$button_key = array_search( $button, $replace_placeholders , true );
|
||||
if ( false !== $key ) {
|
||||
$url = UM()->password()->reset_url();
|
||||
$replace_placeholders[ $button_key ] = esc_html__( 'Set your password', 'ultimate-member' );
|
||||
if ( true === (bool) get_user_meta( um_user( 'ID' ), 'um_password_generated', true ) ) {
|
||||
$replace_placeholders[] = um_user( 'password_reset_link' );
|
||||
$replace_placeholders[] = esc_html__( 'Set your password', 'ultimate-member' );
|
||||
} else {
|
||||
$replace_placeholders[] = um_get_core_page( 'login' );
|
||||
$replace_placeholders[] = esc_html__( 'Login to our site', 'ultimate-member' );
|
||||
}
|
||||
return $replace_placeholders;
|
||||
}
|
||||
|
||||
@@ -599,6 +599,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
}
|
||||
$this->setcookie( $rp_cookie, false );
|
||||
|
||||
$password_generated = get_user_meta( $user->ID, 'um_password_generated', true );
|
||||
if ( $password_generated ) {
|
||||
delete_user_meta( $user->ID, 'um_password_generated' );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
|
||||
@@ -1690,7 +1690,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
?>
|
||||
*
|
||||
*/
|
||||
function approve( $repeat = true, $args = array() ) {
|
||||
public function approve( $repeat = true ) {
|
||||
$user_id = um_user( 'ID' );
|
||||
|
||||
if ( ! $repeat ) {
|
||||
@@ -1702,7 +1702,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
|
||||
if ( 'awaiting_admin_review' === um_user( 'account_status' ) ) {
|
||||
$userdata = get_userdata( $user_id );
|
||||
|
||||
$this->maybe_generate_password_reset_key( $userdata );
|
||||
@@ -1712,13 +1712,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
} else {
|
||||
//$userdata = get_userdata( $user_id );
|
||||
//get_password_reset_key( $userdata );
|
||||
$welcome_email_args = array();
|
||||
if ( true === (bool) $args['generated_pass'] ) {
|
||||
$welcome_email_args = array(
|
||||
'generated_pass' => 1,
|
||||
);
|
||||
}
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'welcome_email', $welcome_email_args );
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'welcome_email' );
|
||||
}
|
||||
|
||||
$this->set_status( 'approved' );
|
||||
|
||||
@@ -8,12 +8,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
*
|
||||
* @param int $user_id
|
||||
*/
|
||||
function um_post_registration_approved_hook( $user_id, $args ) {
|
||||
function um_post_registration_approved_hook( $user_id ) {
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
UM()->user()->approve( true, $args );
|
||||
UM()->user()->approve( true );
|
||||
}
|
||||
add_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );
|
||||
add_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 1 );
|
||||
|
||||
/**
|
||||
* Account needs email validation.
|
||||
@@ -417,8 +417,10 @@ function um_submit_form_register( $args, $form_data ) {
|
||||
$user_email = $args['user_email'];
|
||||
}
|
||||
|
||||
$generate_password = false;
|
||||
if ( ! isset( $args['user_password'] ) ) {
|
||||
$user_password = UM()->validation()->generate( 8 );
|
||||
$generate_password = true;
|
||||
$user_password = UM()->validation()->generate( 8 );
|
||||
} else {
|
||||
$user_password = $args['user_password'];
|
||||
}
|
||||
@@ -456,9 +458,6 @@ function um_submit_form_register( $args, $form_data ) {
|
||||
'user_password' => $user_password,
|
||||
'user_email' => trim( $user_email ),
|
||||
);
|
||||
if ( ! isset( $args['user_password'] ) ) {
|
||||
$credentials['generated_pass'] = true;
|
||||
}
|
||||
|
||||
// @todo test when ready maybe remove
|
||||
if ( ! empty( $args['submitted'] ) ) {
|
||||
@@ -523,6 +522,10 @@ function um_submit_form_register( $args, $form_data ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( true === $generate_password ) {
|
||||
update_user_meta( $user_id, 'um_password_generated', true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires after complete UM user registration.
|
||||
*
|
||||
|
||||
@@ -21,9 +21,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
||||
<div style="padding: 0 30px 30px 30px;border-bottom: 3px solid #eeeeee;">
|
||||
|
||||
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">Thank you for signing up!<span style="display: block;">Your account is now active.</span></div>
|
||||
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">Thank you for signing up! <span style="display: block;">Your account is now active.</span></div>
|
||||
|
||||
<div style="padding: 10px 0 50px 0;text-align: center;"><a href="{login_url}" style="background: #555555;color: #fff;padding: 12px 30px;text-decoration: none;border-radius: 3px;letter-spacing: 0.3px;">{login_button}</a></div>
|
||||
<div style="padding: 10px 0 50px 0;text-align: center;"><a href="{action_url}" style="background: #555555;color: #fff;padding: 12px 30px;text-decoration: none;border-radius: 3px;letter-spacing: 0.3px;">{action_title}</a></div>
|
||||
|
||||
<div style="padding:20px;">If you have any problems, please contact us at <a href="mailto:{admin_email}" style="color: #3ba1da;text-decoration: none">{admin_email}</a></div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user