Changeset 45713 for trunk/src/wp-includes/user.php
- Timestamp:
- 08/01/2019 05:12:42 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r45708 r45713 1603 1603 $user_nicename = sanitize_title( $user_nicename ); 1604 1604 1605 // Store values to save in user meta.1606 $meta = array();1607 1608 1605 /** 1609 1606 * Filters a user's nicename before the user is created or updated. … … 1615 1612 $user_nicename = apply_filters( 'pre_user_nicename', $user_nicename ); 1616 1613 1617 $raw_user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url']; 1618 1619 /** 1620 * Filters a user's URL before the user is created or updated. 1621 * 1622 * @since 2.0.3 1623 * 1624 * @param string $raw_user_url The user's URL. 1625 */ 1626 $user_url = apply_filters( 'pre_user_url', $raw_user_url ); 1614 $user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $user_nicename, $user_login ) ); 1615 1616 if ( $user_nicename_check ) { 1617 $suffix = 2; 1618 while ( $user_nicename_check ) { 1619 // user_nicename allows 50 chars. Subtract one for a hyphen, plus the length of the suffix. 1620 $base_length = 49 - mb_strlen( $suffix ); 1621 $alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix"; 1622 $user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login ) ); 1623 $suffix++; 1624 } 1625 $user_nicename = $alt_user_nicename; 1626 } 1627 1627 1628 1628 $raw_user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email']; … … 1649 1649 } 1650 1650 1651 $raw_user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url']; 1652 1653 /** 1654 * Filters a user's URL before the user is created or updated. 1655 * 1656 * @since 2.0.3 1657 * 1658 * @param string $raw_user_url The user's URL. 1659 */ 1660 $user_url = apply_filters( 'pre_user_url', $raw_user_url ); 1661 1662 $user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered']; 1663 1651 1664 if ( isset( $userdata['spam'] ) && ! is_multisite() ) { 1652 1665 return new WP_Error( 'no_spam', __( 'Sorry, marking a user as spam is only supported on Multisite.' ) ); … … 1654 1667 1655 1668 $spam = empty( $userdata['spam'] ) ? 0 : (bool) $userdata['spam']; 1669 1670 // Store values to save in user meta. 1671 $meta = array(); 1656 1672 1657 1673 $nickname = empty( $userdata['nickname'] ) ? $user_login : $userdata['nickname']; … … 1736 1752 $meta['use_ssl'] = empty( $userdata['use_ssl'] ) ? 0 : (bool) $userdata['use_ssl']; 1737 1753 1738 $user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered'];1739 1740 1754 $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front']; 1741 1755 1742 1756 $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : ''; 1743 1757 1744 $user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $user_nicename, $user_login ) ); 1745 1746 if ( $user_nicename_check ) { 1747 $suffix = 2; 1748 while ( $user_nicename_check ) { 1749 // user_nicename allows 50 chars. Subtract one for a hyphen, plus the length of the suffix. 1750 $base_length = 49 - mb_strlen( $suffix ); 1751 $alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix"; 1752 $user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login ) ); 1753 $suffix++; 1754 } 1755 $user_nicename = $alt_user_nicename; 1756 } 1757 1758 $compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 1758 $compacted = compact( 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'display_name' ); 1759 1759 $data = wp_unslash( $compacted ); 1760 1760
Note: See TracChangeset
for help on using the changeset viewer.