sanitize_email example

<?php if ( $_POST ) {

    check_admin_referer( 'install-network-1' );

    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    // Create network tables.     install_network();
    $base              = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
    $subdomain_install = allow_subdomain_install() ? ! empty( $_POST['subdomain_install'] ) : false;
    if ( ! network_domain_check() ) {
        $result = populate_network( 1, get_clean_basedomain()sanitize_email( $_POST['email'] )wp_unslash( $_POST['sitename'] )$base$subdomain_install );
        if ( is_wp_error( $result ) ) {
            if ( 1 === count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) {
                network_step2( $result );
            } else {
                network_step1( $result );
            }
        } else {
            network_step2();
        }
    } else {
        network_step2();
    }
$errors = new WP_Error();

    $orig_username = $user_name;
    $user_name     = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );

    if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) {
        $errors->add( 'user_name', __( 'Usernames can only contain lowercase letters (a-z) and numbers.' ) );
        $user_name = $orig_username;
    }

    $user_email = sanitize_email( $user_email );

    if ( empty( $user_name ) ) {
        $errors->add( 'user_name', __( 'Please enter a username.' ) );
    }

    $illegal_names = get_site_option( 'illegal_names' );
    if ( ! is_array( $illegal_names ) ) {
        $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
        add_site_option( 'illegal_names', $illegal_names );
    }
    if ( in_array( $user_name$illegal_names, true ) ) {
        
$original_value = $value;
    $error          = null;

    switch ( $option ) {
        case 'admin_email':
        case 'new_admin_email':
            $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
            if ( is_wp_error( $value ) ) {
                $error = $value->get_error_message();
            } else {
                $value = sanitize_email( $value );
                if ( ! is_email( $value ) ) {
                    $error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' );
                }
            }
            break;

        case 'thumbnail_size_w':
        case 'thumbnail_size_h':
        case 'medium_size_w':
        case 'medium_size_h':
        case 'medium_large_size_w':
        
/* * Set the author using the email address (From or Reply-To, the last used) * otherwise use the site admin. */
            if ( ! $author_found && preg_match( '/^(From|Reply-To): /', $line ) ) {
                if ( preg_match( '|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line$matches ) ) {
                    $author = $matches[0];
                } else {
                    $author = trim( $line );
                }
                $author = sanitize_email( $author );
                if ( is_email( $author ) ) {
                    $userdata = get_user_by( 'email', $author );
                    if ( ! empty( $userdata ) ) {
                        $post_author  = $userdata->ID;
                        $author_found = true;
                    }
                }
            }

            if ( preg_match( '/Date: /i', $line ) ) { // Of the form '20 Mar 2002 20:32:37 +0100'.                 $ddate = str_replace( 'Date: ', '', trim( $line ) );
                
wp_die( __( 'Missing site title.' ) );
    }

    if ( empty( $domain ) ) {
        wp_die( __( 'Missing or invalid site address.' ) );
    }

    if ( isset( $blog['email'] ) && '' === trim( $blog['email'] ) ) {
        wp_die( __( 'Missing email address.' ) );
    }

    $email = sanitize_email( $blog['email'] );
    if ( ! is_email( $email ) ) {
        wp_die( __( 'Invalid email address.' ) );
    }

    if ( is_subdomain_install() ) {
        $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', get_network()->domain );
        $path      = get_network()->path;
    } else {
        $newdomain = get_network()->domain;
        $path      = get_network()->path . $domain . '/';
    }

    

function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array()$status = 'pending' ) {
    $email_address = sanitize_email( $email_address );
    $action_name   = sanitize_key( $action_name );

    if ( ! is_email( $email_address ) ) {
        return new WP_Error( 'invalid_email', __( 'Invalid email address.' ) );
    }

    if ( ! in_array( $action_name_wp_privacy_action_request_types(), true ) ) {
        return new WP_Error( 'invalid_action', __( 'Invalid action name.' ) );
    }

    if ( ! in_array( $status, array( 'pending', 'confirmed' ), true ) ) {
        
wp_die( __( 'Cannot create an empty user.' ) );
    }

    $user = wp_unslash( $_POST['user'] );

    $user_details = wpmu_validate_user_signup( $user['username']$user['email'] );

    if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
        $add_user_errors = $user_details['errors'];
    } else {
        $password = wp_generate_password( 12, false );
        $user_id  = wpmu_create_user( esc_html( strtolower( $user['username'] ) )$passwordsanitize_email( $user['email'] ) );

        if ( ! $user_id ) {
            $add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) );
        } else {
            /** * Fires after a new user has been created via the network user-new.php page. * * @since 4.4.0 * * @param int $user_id ID of the newly created user. */
            
Home | Imprint | This part of the site doesn't use cookies.