Created
December 10, 2020 09:21
-
-
Save andrewlimaza/6b356b7e8f0fbe0ece7854dc05a2712e to your computer and use it in GitHub Desktop.
Add a 'Show Password' on Paid Memberships Pro login page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add a checkbox to frontend login page of WordPress to toggle the password text visible/hidden. | |
* | |
* Add this code to a custom plugin or Code Snippets Add On: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* Source: https://www.w3schools.com/howto/howto_js_toggle_password.asp | |
*/ | |
function my_pmpro_show_password_login_toggle( $items, $args ) { | |
$items .= '<input type="checkbox" onclick="my_show_password()"> Show Password'; | |
?> | |
<script> | |
function my_show_password() { | |
var x = document.getElementById("user_pass"); | |
if (x.type === "password") { | |
x.type = "text"; | |
} else { | |
x.type = "password"; | |
} | |
} | |
</script> | |
<?php | |
return $items; | |
} | |
add_filter( 'login_form_middle', 'my_pmpro_show_password_login_toggle', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To match the font settings of "remember me" add a label tag to the snippet:
Hello,
$items .= '<label><input type="checkbox" onclick="my_show_password()"> Show Password</label>';