Ticket #27881: 27881-user.diff
File 27881-user.diff, 5.7 KB (added by , 10 years ago) |
---|
-
src/wp-includes/user.php
1643 1643 } else { 1644 1644 $user_nicename = $userdata['user_nicename']; 1645 1645 } 1646 1647 // store values to save in user meta 1648 $meta = array(); 1649 1646 1650 /** 1647 1651 * Filter a user's nicename before the user is created or updated. 1648 1652 * … … 1652 1656 */ 1653 1657 $user_nicename = apply_filters( 'pre_user_nicename', $user_nicename ); 1654 1658 1655 $ user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url'];1659 $raw_user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url']; 1656 1660 1657 1661 /** 1658 1662 * Filter a user's URL before the user is created or updated. … … 1661 1665 * 1662 1666 * @param string $user_url The user's URL. 1663 1667 */ 1664 $user_url = apply_filters( 'pre_user_url', $ user_url );1668 $user_url = apply_filters( 'pre_user_url', $raw_user_url ); 1665 1669 1666 $ user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email'];1670 $raw_user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email']; 1667 1671 1668 1672 /** 1669 1673 * Filter a user's email before the user is created or updated. … … 1672 1676 * 1673 1677 * @param string $user_email The user's email. 1674 1678 */ 1675 $user_email = apply_filters( 'pre_user_email', $ user_email );1679 $user_email = apply_filters( 'pre_user_email', $raw_user_email ); 1676 1680 1677 1681 if ( ! $update && ! defined( 'WP_IMPORTING' ) && email_exists( $user_email ) ) { 1678 1682 return new WP_Error( 'existing_user_email', __( 'Sorry, that email address is already used!' ) ); … … 1685 1689 * 1686 1690 * @param string $nickname The user's nickname. 1687 1691 */ 1688 $ nickname= apply_filters( 'pre_user_nickname', $nickname );1692 $meta['nickname'] = apply_filters( 'pre_user_nickname', $nickname ); 1689 1693 1690 1694 $first_name = empty( $userdata['first_name'] ) ? '' : $userdata['first_name']; 1691 1695 … … 1696 1700 * 1697 1701 * @param string $first_name The user's first name. 1698 1702 */ 1699 $ first_name= apply_filters( 'pre_user_first_name', $first_name );1703 $meta['first_name'] = apply_filters( 'pre_user_first_name', $first_name ); 1700 1704 1701 1705 $last_name = empty( $userdata['last_name'] ) ? '' : $userdata['last_name']; 1702 1706 … … 1707 1711 * 1708 1712 * @param string $last_name The user's last name. 1709 1713 */ 1710 $ last_name= apply_filters( 'pre_user_last_name', $last_name );1714 $meta['last_name'] = apply_filters( 'pre_user_last_name', $last_name ); 1711 1715 1712 1716 if ( empty( $userdata['display_name'] ) ) { 1713 1717 if ( $update ) { 1714 1718 $display_name = $user_login; 1715 } elseif ( $ first_name && $last_name) {1719 } elseif ( $meta['first_name'] && $meta['last_name'] ) { 1716 1720 /* translators: 1: first name, 2: last name */ 1717 $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $ first_name, $last_name);1718 } elseif ( $ first_name) {1719 $display_name = $ first_name;1720 } elseif ( $ last_name) {1721 $display_name = $ last_name;1721 $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'] ); 1722 } elseif ( $meta['first_name'] ) { 1723 $display_name = $meta['first_name']; 1724 } elseif ( $meta['last_name'] ) { 1725 $display_name = $meta['last_name']; 1722 1726 } else { 1723 1727 $display_name = $user_login; 1724 1728 } … … 1744 1748 * 1745 1749 * @param string $description The user's description. 1746 1750 */ 1747 $ description= apply_filters( 'pre_user_description', $description );1751 $meta['description'] = apply_filters( 'pre_user_description', $description ); 1748 1752 1749 $ rich_editing= empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing'];1753 $meta['rich_editing'] = empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing']; 1750 1754 1751 $ comment_shortcuts= empty( $userdata['comment_shortcuts'] ) ? 'false' : $userdata['comment_shortcuts'];1755 $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) ? 'false' : $userdata['comment_shortcuts']; 1752 1756 1753 1757 $admin_color = empty( $userdata['admin_color'] ) ? 'fresh' : $userdata['admin_color']; 1754 $ admin_color= preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color );1758 $meta['admin_color'] = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color ); 1755 1759 1756 $ use_ssl= empty( $userdata['use_ssl'] ) ? 0 : $userdata['use_ssl'];1760 $meta['use_ssl'] = empty( $userdata['use_ssl'] ) ? 0 : $userdata['use_ssl']; 1757 1761 1758 1762 $user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered']; 1759 1763 1760 $ show_admin_bar_front= empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];1764 $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front']; 1761 1765 1762 1766 $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)); 1763 1767 … … 1771 1775 $user_nicename = $alt_user_nicename; 1772 1776 } 1773 1777 1774 $ data= compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );1775 $data = wp_unslash( $ data);1778 $compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 1779 $data = wp_unslash( $compacted ); 1776 1780 1777 1781 if ( $update ) { 1778 1782 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) ); … … 1784 1788 1785 1789 $user = new WP_User( $user_id ); 1786 1790 1787 foreach ( _get_additional_user_keys( $user ) as $key ) { 1788 if ( isset( $$key ) ) { 1789 update_user_meta( $user_id, $key, $$key ); 1791 foreach ( $meta as $key => $value ) { 1792 update_user_meta( $user_id, $key, $value ); 1793 } 1794 1795 foreach ( wp_get_user_contact_methods( $user ) as $key => $value ) { 1796 if ( isset( $userdata[ $key ] ) ) { 1797 update_user_meta( $user_id, $key, $userdata[ $key ] ); 1790 1798 } 1791 1799 } 1792 1800