Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/25/2015 01:35:15 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Users: Introduce bbp_notice_edit_user_email_change() to notify user of a pending email address change to their account. See #2780.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/template.php

    r5658 r5661  
    11631163
    11641164/**
    1165  * Edit profile success message
     1165 * Display profile edit success notice on user edit page
    11661166 *
    11671167 * @since bbPress (r2688)
     
    11711171 */
    11721172function bbp_notice_edit_user_success() {
    1173     if ( isset( $_GET['updated'] ) && ( bbp_is_single_user() || bbp_is_single_user_edit() ) ) : ?>
     1173
     1174    // Bail if no updated argument
     1175    if ( empty( $_GET['updated'] ) ) {
     1176        return;
     1177    }
     1178
     1179    // Bail if not on users own profile
     1180    if ( ! bbp_is_single_user_edit() ) {
     1181        return;
     1182    } ?>
    11741183
    11751184    <div class="bbp-template-notice updated">
     
    11791188    </div>
    11801189
    1181     <?php endif;
     1190    <?php
     1191}
     1192
     1193/**
     1194 * Display pending email change notice on user edit page
     1195 *
     1196 * @since bbPress (r5660)
     1197 *
     1198 * @uses bbp_get_displayed_user_id()     To get the displayed user ID
     1199 * @uses bbp_is_single_user_edit()       To check if it's the profile edit page
     1200 * @uses bbp_get_user_profile_edit_url() To get the displayed user profile edit URL
     1201 * @uses add_query_arg()                 To add dismiss query argument to URL
     1202 * @uses wp_nonce_url()                  To add nonce to URL
     1203 */
     1204function bbp_notice_edit_user_pending_email() {
     1205
     1206    // Bail if not on users own profile
     1207    if ( ! bbp_is_user_home_edit() ) {
     1208        return;
     1209    }
     1210
     1211    // Check for pending email address change
     1212    $user_id   = bbp_get_displayed_user_id();
     1213    $key       = $user_id . '_new_email';
     1214    $new_email = get_option( $key );
     1215
     1216    // Bail if no pending email address change
     1217    if ( empty( $new_email['newemail'] ) ) {
     1218        return;
     1219    }
     1220
     1221    // Build the nonced URL to dismiss the pending change
     1222    $user_url = bbp_get_user_profile_edit_url( $user_id );
     1223    $nonce    = "dismiss-{$key}";
     1224    $args     = array(
     1225        'action'  => 'bbp-update-user-email',
     1226        'dismiss' => $key
     1227    );
     1228
     1229    // Build the variables to pass into printf()
     1230    $dismiss_url  = wp_nonce_url( add_query_arg( $args, $user_url ), $nonce );
     1231    $dismiss_link = '<a href="' . $dismiss_url . '">' . esc_html_x( 'Cancel', 'Dismiss pending user email address change', 'bbpress' ) . '</a>';
     1232    $coded_email  = '<code>' . esc_html( $new_email['newemail'] ) . '</code>'; ?>
     1233
     1234    <div class="bbp-template-notice info">
     1235        <ul>
     1236            <li><?php printf( __( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ), $coded_email, $dismiss_link ); ?></li>
     1237        </ul>
     1238    </div>
     1239
     1240    <?php
    11821241}
    11831242
Note: See TracChangeset for help on using the changeset viewer.