Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/29/2012 06:47:11 PM (13 years ago)
Author:
boonebgorges
Message:

Fixes email validation in Settings component

When changing your email in the Settings component, this changeset ensures that
the new address is validated in all the crucial ways, specifically the
banned_email_domains and limited_email_domains checks on WordPress Multisite.

Fixes #4485

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-settings/bp-settings-actions.php

    r6183 r6269  
    7272                if ( $bp->displayed_user->userdata->user_email != $user_email ) {
    7373
    74                     // Is email valid
    75                     if ( !is_email( $user_email ) )
    76                         $email_error = 'invalid';
    77 
    78                     // Get blocked email domains
    79                     $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' );
    80 
    81                     // If blocked email domains exist, see if this is one of them
    82                     if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
    83                         $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
    84 
    85                         if ( in_array( $emaildomain, (array) $limited_email_domains ) == false ) {
     74                    // Run some tests on the email address
     75                    $email_checks = bp_core_validate_email_address( $user_email );
     76
     77                    if ( true !== $email_checks ) {
     78                        if ( isset( $email_checks['invalid'] ) ) {
     79                            $email_error = 'invalid';
     80                        }
     81
     82                        if ( isset( $email_checks['domain_banned'] ) || isset( $email_checks['domain_not_allowed'] ) ) {
    8683                            $email_error = 'blocked';
    8784                        }
    88                     }
    89 
    90                     // No errors, and email address doesn't match
    91                     if ( ( false === $email_error ) && email_exists( $user_email ) ) {
    92                         $email_error = 'taken';
     85
     86                        if ( isset( $email_checks['in_use'] ) ) {
     87                            $email_error = 'taken';
     88                        }
    9389                    }
    9490
Note: See TracChangeset for help on using the changeset viewer.