password_reset.php
3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/*
* Template Name: Password Reset
*/
?>
<?php get_header(); ?>
<div id="homecontent" class="home-content">
<div id="login-wrap">
<div id="container">
<h2>Password Reset</h2>
<?php while (have_posts()) : the_post(); ?>
<article id="page-<?php the_ID(); ?>" class="meta-box hentry">
<div id="resetPassword">
<div id="message"></div>
<!--this check on the link key and user login/username-->
<?php
$errors = new WP_Error();
$user = check_password_reset_key($_GET['key'], $_GET['login']);
if (is_wp_error($user)) {
if ($user->get_error_code() == 'expired_key')
$errors->add(
'expiredkey',
__('Sorry, this key has expired. To gain access to your account, <a href="https://thecommonwell.ca/lost-password/">request a password reset key.</a>')
);
else
$errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
}
// display error message
if ($errors->get_error_code()) {
echo '<span style="color:red;">' . $errors->get_error_message($errors->get_error_code()) . '</span>';
} else {
?>
<form id="resetPasswordForm" method="post" autocomplete="off">
<?php
// this prevent automated script for unwanted spam
if (function_exists('wp_nonce_field'))
wp_nonce_field('rs_user_reset_password_action', 'rs_user_reset_password_nonce');
?>
<input type="hidden" name="user_key" id="user_key" value="<?php echo esc_attr($_GET['key']); ?>" autocomplete="off" />
<input type="hidden" name="user_login" id="user_login" value="<?php echo esc_attr($_GET['login']); ?>" autocomplete="off" />
<p>
<label for="pass1"><?php _e('New password') ?><br />
<input type="password" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" /></label>
</p>
<p>
<label for="pass2"><?php _e('Confirm new password') ?><br />
<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /></label>
</p>
<p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & ).'); ?></p>
<br class="clear" />
<?php
/**
* Fires following the 'Strength indicator' meter in the user password reset form.
*
* @since 3.9.0
*
* @param WP_User $user User object of the user whose password is being reset.
*/
do_action('resetpass_form', $user);
?>
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" />
</p>
<?php } ?>
</form>
</div>
</article>
<?php endwhile; ?>
</div><!-- .main-column -->
</div>
</div>
<style>
.error {
color: red !important;
}
</style>
<?php get_footer(); ?>