• Resolved Torsten H?ndler

    (@shogathu)


    Hi,

    is it possible to add an checkbox under the password field for show/hide password?
    Or can you give please an example how to add checkbox with value and not pre checked?

    I use the filter for wpmem_login_form_defaults and can add a checkbox but the checkbox is always checked when loading and I can’t change it and I can’t give the checkbox a value

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • asw

    (@astreetweb)

    I did not figure out a way to add show/hide password but was able to remove the obfusication (stars) with this function. YMMV

    /**
     * Make password text visible in WP-members login form.
     */
    
    add_filter( 'wpmem_login_form_defaults', function( $args ) {
        $args['inputs'][1]['type'] = "text";
        return $args;
    });
    Thread Starter Torsten H?ndler

    (@shogathu)

    @astreetweb thanks but that is not a good solution

    But I found another solution by using the ‘wpmem_login_form_rows’

    asw

    (@astreetweb)

    care to share?

    Thread Starter Torsten H?ndler

    (@shogathu)

    @astreetweb

    sure, I add in my plugin

    function my_plugin_show_hide_pw_wp_members( $rows, $action, $arr ) {
    $rows[1]['field_after'] = '<a class="password-toggle-icon"><i class="fas fa-eye"></i></a>';
    $rows[1]['row_after'] = '<script type="text/javascript">
    const passwordField = document.getElementById("pwd");
    const togglePassword = document.querySelector(".password-toggle-icon i");

    togglePassword.addEventListener("click", function () {
    if (passwordField.type === "password") {
    passwordField.type = "text";
    togglePassword.classList.remove("fa-eye");
    togglePassword.classList.add("fa-eye-slash");
    } else {
    passwordField.type = "password";
    togglePassword.classList.remove("fa-eye-slash");
    togglePassword.classList.add("fa-eye");
    }
    });
    </script>
    ';

    return $rows;
    }

    add_filter( 'wpmem_login_form_rows', 'my_plugin_show_hide_pw_wp_members', 10, 3 );

    and add some css

    #wpmem_login_form .div_text {
    position: relative;
    }

    .password-toggle-icon {
    position: absolute;
    top: 30px;
    right: 10px;
    transform: translateY(-50%);
    cursor: pointer;
    }

    .password-toggle-icon i {
    font-size: 18px;
    line-height: 1;

    transition: color 0.3s ease-in-out;
    margin-bottom: 20px;
    }

    .password-toggle-icon i:hover {
    color: #000;
    }

    this is based on font awesome.

    I hope this helps you

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.