Merge pull request #804 from ultimatemember/feature/activation_link_expiration

Activation link expiration
This commit is contained in:
Nikita Sinelnikov
2021-04-12 12:26:58 +03:00
committed by GitHub
4 changed files with 21 additions and 1 deletions
+7 -1
View File
@@ -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(
+1
View File
@@ -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' );
+5
View File
@@ -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();
+8
View File
@@ -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