Toggle your password entry in UM forms. Helps prevent password entry mistakes
/*---------------------------------------------*/
/**
* Ultimate Member - Toggle password fields in forms
*/
/*----------------------------------------------*/
add_filter("um_confirm_user_password_form_edit_field","um_user_password_form_edit_field", 10, 2 );
add_filter("um_user_password_form_edit_field","um_user_password_form_edit_field", 10, 2 );
function um_user_password_form_edit_field( $output, $set_mode ){
ob_start();
?>
<div id='um-field-show-passwords-<?php echo $set_mode;?>' style='text-align:right;display:block;'>
<i class='um-faicon-eye-slash'></i>
<a href='#'><?php _e("Show password","ultimate-member"); ?></a>
</div>
<script type='text/javascript'>
jQuery('div[id="um-field-show-passwords-<?php echo $set_mode;?>"] a').click(function(){
var $parent = jQuery(this).parent("div");
var $form = jQuery(".um-<?php echo $set_mode;?> .um-form");
$parent.find("i").toggleClass(function() {
if ( jQuery( this ).hasClass( "um-faicon-eye-slash" ) ) {
$parent.find("a").text('<?php _e("Hide password","ultimate-member"); ?>');
jQuery( this ).removeClass( "um-faicon-eye-slash" )
$form.find(".um-field-password").find("input[type=password]").attr("type","text");
return "um-faicon-eye";
}
jQuery( this ).removeClass( "um-faicon-eye" );
$parent.find("a").text('<?php _e("Show password","ultimate-member"); ?>');
$form.find(".um-field-password").find("input[type=text]").attr("type","password");
return "um-faicon-eye-slash";
});
return false;
});
</script>
<?php
return $output.ob_get_clean();
}
Code language: JavaScript (javascript)