Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add a 'Show Password' on Paid Memberships Pro login page.
<?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