1 | <?php |
---|
2 | /** |
---|
3 | * The post-pending-email-confirm profile-fields Template |
---|
4 | * |
---|
5 | * @package wporg-login |
---|
6 | */ |
---|
7 | |
---|
8 | $sso = WPOrg_SSO::get_instance(); |
---|
9 | |
---|
10 | // Migrate to cookies. |
---|
11 | if ( !empty( $sso::$matched_route_params['profile_user'] ) ) { |
---|
12 | setcookie( 'wporg_profile_user', $sso::$matched_route_params['profile_user'], time()+DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true ); |
---|
13 | setcookie( 'wporg_profile_key', $sso::$matched_route_params['profile_key'], time()+DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true ); |
---|
14 | |
---|
15 | wp_safe_redirect( '/register/create-profile' ); |
---|
16 | die(); |
---|
17 | } |
---|
18 | |
---|
19 | $profile_user = $_COOKIE['wporg_profile_user'] ?? false; |
---|
20 | $profile_key = $_COOKIE['wporg_profile_key'] ?? false; |
---|
21 | |
---|
22 | $pending_user = wporg_get_pending_user( $profile_user ); |
---|
23 | |
---|
24 | // Already logged in.. Warn about duplicate accounts, etc. |
---|
25 | if ( is_user_logged_in() ) { |
---|
26 | wp_safe_redirect( home_url( '/linkexpired/register-logged-in' ) ); |
---|
27 | exit; |
---|
28 | } |
---|
29 | |
---|
30 | $can_access = false; |
---|
31 | if ( $pending_user && $pending_user['user_profile_key'] ) { |
---|
32 | $expiration_duration = DAY_IN_SECONDS; // The profile-edit screen is short lived. |
---|
33 | |
---|
34 | list( $user_request_time, $hashed_profile_key ) = explode( ':', $pending_user['user_profile_key'], 2 ); |
---|
35 | $expiration_time = $user_request_time + $expiration_duration; |
---|
36 | |
---|
37 | $hash_is_correct = wp_check_password( $profile_key, $hashed_profile_key ); |
---|
38 | |
---|
39 | if ( $hash_is_correct && time() < $expiration_time ) { |
---|
40 | $can_access = true; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | if ( $can_access && $pending_user['created'] ) { |
---|
45 | wp_safe_redirect( home_url( '/linkexpired/account-created/' . urlencode( $pending_user['user_login'] ) ) ); |
---|
46 | die(); |
---|
47 | } elseif ( ! $can_access ) { |
---|
48 | wp_safe_redirect( home_url( '/linkexpired' ) ); |
---|
49 | die(); |
---|
50 | } |
---|
51 | |
---|
52 | if ( wporg_login_save_profile_fields( $pending_user, 'pending' ) ) { |
---|
53 | // re-fetch the user, it's probably changed. |
---|
54 | $pending_user = wporg_get_pending_user( $profile_user ); |
---|
55 | } |
---|
56 | wp_enqueue_script( 'wporg-registration' ); |
---|
57 | |
---|
58 | // Allow changing the email, if they've not already changed it once. |
---|
59 | $email_change_available = empty( $pending_user['meta']['changed_email'] ); |
---|
60 | |
---|
61 | get_header(); |
---|
62 | ?> |
---|
63 | <form name="registerform" id="registerform" action="" method="post"> |
---|
64 | |
---|
65 | <div class="message info"> |
---|
66 | <p><?php |
---|
67 | if ( $pending_user['cleared'] ) { |
---|
68 | printf( |
---|
69 | /* translators: %s Email address */ |
---|
70 | __( 'Please check your email %s for a confirmation link to set your password.', 'wporg' ) . |
---|
71 | '<br><br>' . '<a href="#" class="resend" data-account="%s">' . __( 'Resend confirmation email.', 'wporg' ) . '</a>' . |
---|
72 | ( $email_change_available ? '<br>' . '<a href="#" class="change-email">' . __( 'Incorrect email? Update email address.', 'wporg' ) . '</a>' : '' ), |
---|
73 | '<code>' . esc_html( $pending_user['user_email'] ) . '</code>', |
---|
74 | esc_attr( $pending_user['user_email'] ) |
---|
75 | ); |
---|
76 | } else { |
---|
77 | printf( |
---|
78 | /* translators: %s Email address */ |
---|
79 | __( 'Your account is pending approval. You will receive an email at %s to set your password when approved.', 'wporg' ) . |
---|
80 | '<br>' . __( 'Please contact %s for more details.', 'wporg' ) . |
---|
81 | ( $email_change_available ? '<br><br>' . '<a href="#" class="change-email">' . __( 'Incorrect email? Update email address.', 'wporg' ) . '</a>' : '' ), |
---|
82 | '<code>' . esc_html( $pending_user['user_email'] ) . '</code>', |
---|
83 | '<a href="mailto:' . $sso::SUPPORT_EMAIL . '">' . $sso::SUPPORT_EMAIL . '</a>' |
---|
84 | ); |
---|
85 | } |
---|
86 | ?></p> |
---|
87 | </div> |
---|
88 | |
---|
89 | <p class="intro"> |
---|
90 | <?php _e( 'Complete your WordPress.org Profile information.', 'wporg' ); ?> |
---|
91 | </p> |
---|
92 | |
---|
93 | <p class="login-login"> |
---|
94 | <label for="user_login"><?php _e( 'Username', 'wporg' ); ?></label> |
---|
95 | <input type="text" disabled="disabled" class=" disabled" value="<?php echo esc_attr( $profile_user ); ?>" size="20" /> |
---|
96 | </p> |
---|
97 | |
---|
98 | <p class="login-email hidden"> |
---|
99 | <label for="user_email"><?php _e( 'Email', 'wporg' ); ?></label> |
---|
100 | <input type="text" name="user_email" value="<?php echo esc_attr( $pending_user['user_email'] ); ?>" size="20" maxlength="100" /> |
---|
101 | </p> |
---|
102 | |
---|
103 | <?php |
---|
104 | $fields = &$pending_user['meta']; |
---|
105 | include __DIR__ . '/partials/register-profilefields.php'; |
---|
106 | ?> |
---|
107 | |
---|
108 | <p class="login-submit"> |
---|
109 | <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary" value="<?php esc_attr_e( 'Save Profile Information', 'wporg' ); ?>" /> |
---|
110 | </p> |
---|
111 | |
---|
112 | </form> |
---|
113 | |
---|
114 | <p id="nav"> |
---|
115 | <a href="<?php echo wporg_login_wordpress_url(); ?>"><?php _e( 'WordPress.org', 'wporg' ); ?></a> |
---|
116 | </p> |
---|
117 | |
---|
118 | <?php get_footer(); ?> |
---|