* enhancements related to #1599;

This commit is contained in:
Mykyta Synelnikov
2024-12-19 17:24:52 +02:00
parent a6904639f3
commit a0892e18aa
4 changed files with 635 additions and 607 deletions
+5 -1
View File
@@ -123,7 +123,7 @@ class Site_Health {
'title' => get_the_title( $form_id ),
'link' => get_edit_post_link( $form_id ),
);
$forms_count++;
++$forms_count;
continue 2;
}
}
@@ -656,6 +656,10 @@ class Site_Health {
'label' => __( 'Change Password request limit ', 'ultimate-member' ),
'value' => UM()->options()->get( 'change_password_request_limit' ),
);
$access_other_settings['um-only_approved_user_reset_password'] = array(
'label' => __( 'Only approved user Reset Password', 'ultimate-member' ),
'value' => UM()->options()->get( 'only_approved_user_reset_password' ),
);
$access_other_settings['um-blocked_emails'] = array(
'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
'value' => stripslashes( $blocked_emails ),
+34 -14
View File
@@ -262,7 +262,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
if ( 'publish' === get_post_status( $opt_value ) ) {
$title = get_the_title( $opt_value );
$title = ( mb_strlen( $title ) > 50 ) ? mb_substr( $title, 0, 49 ) . '...' : $title;
$title = sprintf( __( '%s (ID: %s)', 'ultimate-member' ), $title, $opt_value );
$title = sprintf( __( '%1$s (ID: %2$s)', 'ultimate-member' ), $title, $opt_value );
$options = array( $opt_value => $title );
$page_value = $opt_value;
@@ -840,6 +840,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'change_password_request_limit' => array(
'sanitize' => 'bool',
),
'only_approved_user_reset_password' => array(
'sanitize' => 'bool',
),
'blocked_emails' => array(
'sanitize' => 'textarea',
),
@@ -1074,6 +1077,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'sections' => array(
'' => array(
'title' => __( 'Pages', 'ultimate-member' ),
// translators: %s: Link to UM Docs
'description' => sprintf( __( 'This section enables you to assign a page to one of the core elements necessary for the plugin\'s proper function. The plugin automatically creates and configures the required pages upon installation.<br />You only need to use this tab if you accidentally deleted pages that were automatically created during the initial plugin activation. <a href="%s" target="_blank">Learn more about manually creating pages</a>.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1903-creating-plugin-core-pages-manually' ),
'fields' => $general_pages_fields,
),
@@ -1525,6 +1529,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'checkbox_label' => __( 'Enable limit for changing password', 'ultimate-member' ),
'description' => __( 'This option adds rate limit when submitting the change password form in the Account page. Users are only allowed to submit 1 request per 30 minutes to prevent from any brute-force attacks or password guessing with the form.', 'ultimate-member' ),
),
array(
'id' => 'only_approved_user_reset_password',
'type' => 'checkbox',
'label' => __( 'Only approved user Reset Password', 'ultimate-member' ),
'checkbox_label' => __( 'Enable reset password only for approved users', 'ultimate-member' ),
'description' => __( 'This option makes possible to reset password only for approved user. Is used to prevent from any spam email attacks from not approved users.', 'ultimate-member' ),
),
),
),
'blocked' => array(
@@ -1599,6 +1610,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'form_sections' => array(
'template' => array(
'title' => __( 'Template', 'ultimate-member' ),
// translators: %s: Link to UM docs
'description' => sprintf( __( 'This section allows you to customize the user profile template and size. <a href="%s" target="_blank">Learn more about custom profile template creation</a>.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/120-adding-your-custom-profile-templates' ),
'fields' => array(
array(
@@ -2061,6 +2073,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'sections' => array(
'' => array(
'title' => __( 'General', 'ultimate-member' ),
// translators: %s: Link to UM docs
'description' => sprintf( __( 'Advanced settings section is designed to help you fine-tune your website or add extra features. <a href="%s" target="_blank">Learn more about advanced settings section</a>.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1902-advanced-tab' ),
'fields' => array(
array(
@@ -2091,7 +2104,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'override_templates' => array(
'title' => __( 'Override templates', 'ultimate-member' ),
// translators: %s: Link to the docs article.
'description' => sprintf( __( 'Each time we release an update, you\'ll find a list of changes made to the template files. <a href="%s" target="_blank">Learn more about overriding templates</a>.<br />You can easily check the status of the latest templates to see if they are up-to-date or need updating. <a href="%s" target="_blank">Learn more about fixing outdated templates</a>.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1516-templates-map', 'https://docs.ultimatemember.com/article/1847-fixing-outdated-ultimate-member-templates' ), /** @noinspection HtmlUnknownTarget */
'description' => sprintf( __( 'Each time we release an update, you\'ll find a list of changes made to the template files. <a href="%1$s" target="_blank">Learn more about overriding templates</a>.<br />You can easily check the status of the latest templates to see if they are up-to-date or need updating. <a href="%2$s" target="_blank">Learn more about fixing outdated templates</a>.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1516-templates-map', 'https://docs.ultimatemember.com/article/1847-fixing-outdated-ultimate-member-templates' ),
'fields' => array(
array(
'id' => 'override_templates_list_table',
@@ -2237,9 +2250,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
//sorting licenses
if ( ! empty( $settings['licenses']['fields'] ) ) {
$licenses = $settings['licenses']['fields'];
@uasort( $licenses, function( $a, $b ) {
@uasort(
$licenses,
function ( $a, $b ) {
return strnatcasecmp( $a['label'], $b['label'] );
} );
}
);
$settings['licenses']['fields'] = $licenses;
}
@@ -2247,9 +2263,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
if ( ! empty( $settings['extensions']['sections'] ) ) {
$extensions = $settings['extensions']['sections'];
@uasort( $extensions, function( $a, $b ) {
@uasort(
$extensions,
function ( $a, $b ) {
return strnatcasecmp( $a['title'], $b['title'] );
} );
}
);
$keys = array_keys( $extensions );
$temp = array(
@@ -2540,7 +2559,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
* }
* ?>
*/
do_action( "um_settings_before_save" );
do_action( 'um_settings_before_save' );
/**
* UM hook
@@ -2712,17 +2731,19 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
if ( ! empty( $_POST['um_options'] ) ) {
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
$post_ids = new \WP_Query( array(
$post_ids = new \WP_Query(
array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_um_core',
'compare' => 'EXISTS'
)
'compare' => 'EXISTS',
),
),
'posts_per_page' => -1,
'fields' => 'ids'
) );
'fields' => 'ids',
)
);
$post_ids = $post_ids->get_posts();
@@ -2792,7 +2813,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
}
}
}
} elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
global $wpdb;
@@ -3508,7 +3528,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
}
if ( file_exists( $theme_template_path ) ) {
$fp = fopen( $theme_template_path, "w" );
$fp = fopen( $theme_template_path, 'w' );
$result = fputs( $fp, $content );
fclose( $fp );
}
+1
View File
@@ -691,6 +691,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'enable_reset_password_limit' => true,
'reset_password_limit_number' => 3,
'change_password_request_limit' => false,
'only_approved_user_reset_password' => true,
'blocked_emails' => '',
'blocked_words' => 'admin' . "\r\n" . 'administrator' . "\r\n" . 'webmaster' . "\r\n" . 'support' . "\r\n" . 'staff',
'allowed_choice_callbacks' => '',
+4 -1
View File
@@ -454,10 +454,13 @@ if ( ! class_exists( 'um\core\Password' ) ) {
if ( isset( $data ) && is_a( $data, '\WP_User' ) ) {
um_fetch_user( $data->ID );
if ( false === UM()->options()->get( 'only_approved_user_reset_password' ) || UM()->common()->users()->has_status( $data->ID, 'approved' ) ) {
UM()->user()->password_reset();
}
}
wp_redirect( um_get_core_page('password-reset', 'checkemail' ) );
wp_safe_redirect( um_get_core_page( 'password-reset', 'checkemail' ) );
exit;
}