• Resolved chriswp2021

    (@chriswp2021)


    Hi, I would like to completely and permanently remove the option/tick box enabling users to use a weak password when signing up or resetting their password. The option should be removed in all cases (including when users follow the password reset link in the email they receive in their inbox). I don‘t want to use a plugin to do that – simply removing the option would work for me. I am using a Divi child theme and I am not familiar with coding. So, I‘d be super thankful if you could help me with a step-by-step description of how to achieve the task ?? Thank you very much!!

Viewing 9 replies - 1 through 9 (of 9 total)
  • First, the easiest way is to use the plugin…

    If you don’t want to use any plugin, you shoud hide the option by css.
    Paste below code to the functions.php of your theme (Divi child).

    add_action('login_init', 'no_weak_password_header');
    add_action('admin_head', 'no_weak_password_header');
    function no_weak_password_header()
    {
    echo"<style>.pw-weak{display:none!important}</style>";
    echo'<script>document.getElementById("pw-checkbox").disabled = true;</script>';
    }

    Thread Starter chriswp2021

    (@chriswp2021)

    Hey @aoixtreme – that is so helpful, thank you very much! The functions.php of my Divi child theme looks like this:

    <?php
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    // BEGIN ENQUEUE PARENT ACTION
    // AUTO GENERATED - Do not modify or remove comment markers above or below:
    
    if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
        function chld_thm_cfg_locale_css( $uri ){
            if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
                $uri = get_template_directory_uri() . '/rtl.css';
            return $uri;
        }
    endif;
    add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
    
    if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
        function chld_thm_cfg_parent_css() {
            wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array(  ) );
        }
    endif;
    add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );
    
    // END ENQUEUE PARENT ACTION

    I am unsure where exactly to insert the snippet you mentioned. Could you maybe send me the full functions.php code including your snippet inserted at the right location? This would help me very much and I’d be super thankful ??

    Also, will the new functions.php code remain active after installing a WordPress update? Since it’s a child theme, I guess it does ??

    Have a nice day and again, THANK YOU so much for your help!

    Cheers,
    Christian

    The safest location is the last line in functions.php.

    Full code is here.

    <?php
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    // BEGIN ENQUEUE PARENT ACTION
    // AUTO GENERATED - Do not modify or remove comment markers above or below:
    
    if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
        function chld_thm_cfg_locale_css( $uri ){
            if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
                $uri = get_template_directory_uri() . '/rtl.css';
            return $uri;
        }
    endif;
    add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
    
    if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
        function chld_thm_cfg_parent_css() {
            wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array(  ) );
        }
    endif;
    add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );
    
    // END ENQUEUE PARENT ACTION
    
    add_action('login_init', 'no_weak_password_header');
    add_action('admin_head', 'no_weak_password_header');
    function no_weak_password_header()
    {
        echo"<style>.pw-weak{display:none!important}</style>";
        echo'<script>document.getElementById("pw-checkbox").disabled = true;</script>';
    }

    Also, will the new functions.php code remain active after installing a WordPress update? Since it’s a child theme, I guess it does

    Of course, that’s why we use child themes. Not affected by updates.

    Thread Starter chriswp2021

    (@chriswp2021)

    Hi @aoixtreme – first of all, thank you very much!

    I tried this code and I am getting the following error message when I try to log into the WP backend: “Error: Cookies are blocked due to an unexpected issue. You can find help in this documentation or contact the support forums.”

    I tried twice, but keep receiving the same error message. I keep getting the same error message until I use the old functions.php again. Is there anything else I could try?

    Cheers,
    Christian ??

    I think that error message did not come from PHP process.

    In this case, you may have saved functions.php as text with BOM.

    You shold save functions.php text file as UTF-8 Unicode(WITHOUT BOM).

    What text editor do you using? Some popular text editors use UTF-8 with BOM as the default format to save text files.

    Thread Starter chriswp2021

    (@chriswp2021)

    Hi @aoixtreme – I used TextEdit on a Mac with UTF8 opening and saving mode enabled. I am still encountering the same problem. I can only choose for the UTF8 option. TextEdit doesn’t give me a choice between “with” or “without” UTF8…

    Try download functions.php file via pastebin. There is a download link.
    https://pastebin.pl/view/5d92556c

    I want help you, but I have no good idea anymore..

    Thread Starter chriswp2021

    (@chriswp2021)

    Thank you for your help, anyway! Maybe there is somebody else out there who knows a solution…? ??

    Thread Starter chriswp2021

    (@chriswp2021)

    here seems to be the solution to my problem ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to remove tick box for use of weak passwords’ is closed to new replies.