mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge pull request #804 from ultimatemember/feature/activation_link_expiration
Activation link expiration
This commit is contained in:
@@ -647,7 +647,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
'0' => __( 'No', 'ultimate-member' ),
|
||||
'1' => __( 'Yes', 'ultimate-member' ),
|
||||
]
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'activation_link_expiry_time',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Activation link lifetime', 'ultimate-member' ),
|
||||
'tooltip' => __( 'How long does an activation link live? Leave empty for endless links.', 'ultimate-member' ),
|
||||
),
|
||||
)
|
||||
),
|
||||
'account' => array(
|
||||
|
||||
@@ -577,6 +577,7 @@ if ( ! class_exists( 'um\Config' ) ) {
|
||||
'member_directory_own_table' => 0,
|
||||
'profile_show_html_bio' => 0,
|
||||
'profile_noindex' => 0,
|
||||
'activation_link_expiry_time' => '',
|
||||
);
|
||||
|
||||
add_filter( 'um_get_tabs_from_config', '__return_true' );
|
||||
|
||||
@@ -187,6 +187,11 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$account_secret_hash_expiry = get_user_meta( $user_id, 'account_secret_hash_expiry', true );
|
||||
if ( ! empty( $account_secret_hash_expiry ) && time() > $account_secret_hash_expiry ) {
|
||||
wp_die( __( 'This activation link is expired.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
UM()->user()->approve();
|
||||
um_reset_user();
|
||||
|
||||
@@ -1336,6 +1336,13 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
$this->profile['account_secret_hash'] = UM()->validation()->generate();
|
||||
$this->update_usermeta_info( 'account_secret_hash' );
|
||||
|
||||
$expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
|
||||
if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
|
||||
$this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
|
||||
$this->update_usermeta_info( 'account_secret_hash_expiry' );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -1436,6 +1443,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
$this->set_status( 'approved' );
|
||||
$this->delete_meta( 'account_secret_hash' );
|
||||
$this->delete_meta( 'account_secret_hash_expiry' );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
|
||||
Reference in New Issue
Block a user