John Davidson

javascript - Show Passwords feature in Ultimate Membership pro Forms

0 comments
Message:


How can I add show password field in my forms?
I try this code in my function but didn't work
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();

}



My Answer:
To add a show password field in Ultimate Membership Pro forms, you can use the following code snippet:

javascript
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();
?>





return $output.ob_get_clean();
}


Make sure to add this code to your theme's functions.php file or a custom plugin. This code will add a "Show password" link next to the password field in your Ultimate Membership Pro forms, allowing users to toggle between showing and hiding their password.

Rate this post

3 of 5 based on 6089 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us