• Resolved jlunas16

    (@jlunas16)


    Hi, is it possible to write custom logic or update logic relating to password strength checker? I wrote a custom checker but it gets overridden so I have decided to reach out to persist the logic. As you see in the page there are requirements that needs to be checked before we can say that a password is Strong and is okay. For reference I have attached below the code we wanted to be in the password checking logic. Thanks

    /**
    		 * Retrieve current strength as a number, a slug, or a translated text string
    		 *
    		 * @since 3.0.0
    		 * @since 5.0.0 Allow password confirmation to be optional when checking strength.
    		 *
    		 * @param {String} format Derived return format [int|slug|text] defaults to int.
    		 * @return mixed
    		 */
    		get_current_strength: function( format ) {
    	
    			
    			format   = format || 'int';
    			var pass = this.$pass.val(),
                conf = this.$conf && this.$conf.length ? this.$conf.val() : '',
                val;
    
                var currentValue = pass;
                var hasUppercase = currentValue.match(/[A-Z]/) ? 1 : 0;
                var hasLowercase = currentValue.match(/[a-z]/) ? 1 : 0;
                var hasNumber = currentValue.match(/[0-9]/) ? 1 : 0;
                var hasSymbols = currentValue.match(/[^A-Za-z 0-9]/g) ? 1 : 0;
    
                if (currentValue.length < 8) {
                    val = -1;
                } else {
                    val = hasUppercase + hasLowercase + hasNumber + hasSymbols;
                }
    
                if (conf) {
                    val = pass !== conf ? 5 : val; 
                }
    
    			if ( 'slug' === format ) {
                    return this.get_strength_slug( val );
    			} else if ( 'text' === format ) {
    				return this.get_strength_text( val );
    			} else {
    				return val;
    			}
    		},
    
    

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Nick Mariano

    (@reddotinmotion)

    Hi @jlunas16,

    I understand that you would like to override the get_current_strength method of the LLMS.PasswordStrength object. Let me see how we can help you here.

    To override the get_current_strength method, I first installed and activated the free Code Snippets plugin. Then I went to WordPress Dashboard > Snippets > Add New to create a new snippet. After adding the appropriate snippet title, I pasted the code below. It appears to have worked since I get the "get_current_strength overwritten." message in the logs when I try create a password while trying to register as a new user in the /dashboard/ page. Could you check to see if this approach works for you, too?

    add_action( "wp_footer", "custom_update_llms_password_strength_logic", PHP_INT_MAX );
    function custom_update_llms_password_strength_logic() {
    	?>
    		<script>
    		   (function($){
    			   $.extend(LLMS.PasswordStrength, {
    					get_current_strength: function( format ) {
                            console.log("get_current_strength overwritten.")
    						
    						/* Write your custom logic below.*/
    					}
    			   })
    		   })(jQuery);
    		</script>
    	<?php
    }
    Plugin Support Nadia Akther

    (@nadiaakther)

    Hi @jlunas16,

    Since we haven’t heard back from you in a month, we are going to mark this thread as resolved. Don’t worry; if you have more questions or still need help, just hit reply and let us know!

    All the best,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Lifter LMS Password Strength Checker’ is closed to new replies.