Ticket #25533: 25533.3.diff
| File 25533.3.diff, 16.5 KB (added by , 13 years ago) |
|---|
-
src/wp-includes/user.php
38 38 $credentials['remember'] = false; 39 39 40 40 // TODO do we deprecate the wp_authentication action? 41 do_action_ref_array('wp_authenticate', array(&$credentials['user_login'], &$credentials['user_password'])); 41 /** 42 * Fires before the user is authenticated. 43 * 44 * The variables passed to the callbacks are passed by reference and can be modified by callback functions. 45 * 46 * @since 1.5.2 47 * 48 * @param string $user_login Username, passed by reference. 49 * @param string $user_password User password, passed by reference. 50 */ 51 do_action_ref_array( 'wp_authenticate', array( &$credentials['user_login'], &$credentials['user_password'] ) ); 42 52 43 53 if ( '' === $secure_cookie ) 44 54 $secure_cookie = is_ssl(); 45 55 46 $secure_cookie = apply_filters('secure_signon_cookie', $secure_cookie, $credentials); 56 /** 57 * Filter whether to use a secure sign-on cookie. 58 * 59 * @since 3.1.0 60 * 61 * @param bool $secure_cookie Whether to use a secure sign-on cookie. 62 * @param array $args { 63 * Array of entered sign-on data. 64 * 65 * @type string $user_login Username. 66 * @type string $user_password Password entered. 67 * @type bool $remember Whether to 'remember' the user. Increases the time 68 * that the cookie will be kept. Default false. 69 * } 70 */ 71 $secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials ); 47 72 48 73 global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie 49 74 $auth_secure_cookie = $secure_cookie; … … 61 86 } 62 87 63 88 wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie); 64 do_action('wp_login', $user->user_login, $user); 89 90 /** 91 * Triggered after the user has successfully logged in. 92 * 93 * @since 1.5.2 94 * 95 * @param string $user_login Username. 96 * @param WP_User $user WP_User object of the logged-in user. 97 */ 98 do_action( 'wp_login', $user->user_login, $user ); 65 99 return $user; 66 100 } 67 101 … … 92 126 if ( !$user ) 93 127 return new WP_Error( 'invalid_username', sprintf( __( '<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?' ), wp_lostpassword_url() ) ); 94 128 129 /** 130 * Filter whether the given user can be authenticated with the provided $password. 131 * 132 * @since 2.5.0 133 * 134 * @param WP_User|WP_Error $user WP_User object or WP_Error object if a previous 135 * callback failed authentication. 136 * @param string $password The password to check against the user. 137 */ 95 138 $user = apply_filters('wp_authenticate_user', $user, $password); 96 139 if ( is_wp_error($user) ) 97 140 return $user; … … 138 181 */ 139 182 function wp_authenticate_spam_check( $user ) { 140 183 if ( $user && is_a( $user, 'WP_User' ) && is_multisite() ) { 184 /** 185 * Filter whether the user has been marked as a spammer. 186 * 187 * @since 3.7.0 188 * 189 * @param bool $spammed Whether the user is considered spam. 190 * @param WP_User $user The user to check against. 191 */ 141 192 $spammed = apply_filters( 'check_is_user_spammed', is_user_spammy(), $user ); 142 193 143 194 if ( $spammed ) … … 162 213 163 214 $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); 164 215 165 return apply_filters('get_usernumposts', $count, $userid); 216 /** 217 * Filter the number of posts a user has written. 218 * 219 * @since 2.7.0 220 * 221 * @param int $count The user's post count. 222 * @param int $userid User ID. 223 */ 224 return apply_filters( 'get_usernumposts', $count, $userid ); 166 225 } 167 226 168 227 /** … … 258 317 else 259 318 $result = false; 260 319 261 return apply_filters("get_user_option_{$option}", $result, $option, $user); 320 /** 321 * Filter a specific user option value. 322 * 323 * The dynamic portion of the hook name, $option, refers to 324 * the user option name. 325 * 326 * @since 2.5.0 327 * 328 * @param mixed $result Value for the user's option. 329 * @param string $option Name of the option being retrieved. 330 * @param WP_User $user WP_User object of the user whose option is being retrieved. 331 */ 332 return apply_filters( "get_user_option_{$option}", $result, $option, $user ); 262 333 } 263 334 264 335 /** … … 496 567 $search_columns = array('user_login', 'user_nicename'); 497 568 } 498 569 570 /** 571 * Filter the columns to search in a WP_User_Query search. 572 * 573 * The default columns depend on the search term and include 'user_email', 574 * 'user_login', 'ID', 'user_url' and 'user_nicename'. 575 * 576 * @since 3.6.0 577 * 578 * @param array $search_columns Array of column names to be searched. 579 * @param string $search The text being searched. 580 * @param WP_User_Query $this The current WP_User_Query instance. 581 */ 499 582 $search_columns = apply_filters( 'user_search_columns', $search_columns, $search, $this ); 500 583 501 584 $this->query_where .= $this->get_search_sql( $search, $search_columns, $wild ); … … 548 631 $this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)"; 549 632 } 550 633 634 /** 635 * Fires after the WP_User_Query has been parsed and before 636 * the query is executed. 637 * 638 * The passed WP_User_Query object contains SQL parts formed 639 * from parsing the given query. 640 * 641 * @since 1.5.2 642 * 643 * @param WP_User_Query $this The current WP_User_Query instance, 644 * passed by reference. 645 */ 551 646 do_action_ref_array( 'pre_user_query', array( &$this ) ); 552 647 } 553 648 … … 568 663 $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 569 664 } 570 665 666 /** 667 * Filter SELECT_FOUND_ROWS value for the current WP_User_Query instance. 668 * 669 * @since 3.2.0 670 * 671 * @global wpdb $wpdb WordPress database object. 672 * 673 * @param string $sql The SELECT_FOUND_ROWS() value for the current WP_User_Query. 674 */ 571 675 if ( isset( $qv['count_total'] ) && $qv['count_total'] ) 572 676 $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); 573 677 … … 776 880 } 777 881 } 778 882 883 /** 884 * Filter list of blogs a user belongs to. 885 * 886 * @since 3.1.0 887 * 888 * @param array $blogs An array of blog objects belonging to the user. 889 * @param int $user_id User ID. 890 * @param bool $all Whether the returned blogs array should contain all blog, including 891 * those marked 'deleted', 'archived', or 'spam'. Default false. 892 */ 779 893 return apply_filters( 'get_blogs_of_user', $blogs, $user_id, $all ); 780 894 } 781 895 … … 1094 1208 1095 1209 $output .= "</select>"; 1096 1210 } 1211 1212 /** 1213 * Filter the wp_dropdown_users() HTML output. 1214 * 1215 * @since 2.3.0 1216 * 1217 * @param string $output HTML output generated by wp_dropdown_users(). 1218 */ 1219 $output = apply_filters( 'wp_dropdown_users', $output ); 1097 1220 1098 $output = apply_filters('wp_dropdown_users', $output);1099 1100 1221 if ( $echo ) 1101 1222 echo $output; 1102 1223 … … 1140 1261 1141 1262 if ( 'edit' == $context ) { 1142 1263 if ( $prefixed ) { 1143 $value = apply_filters("edit_{$field}", $value, $user_id); 1264 /** This filter is documented in wp-includes/post.php */ 1265 $value = apply_filters( "edit_{$field}", $value, $user_id ); 1144 1266 } else { 1267 /** 1268 * Filter a user field value in the 'edit' context. 1269 * 1270 * The dynamic portion of the hook name, $field, refers to the prefixed 1271 * user field being filtered, such as 'user_login', 'user_email', 1272 * 'first_name', etc. 1273 * 1274 * @since 2.9.0 1275 * 1276 * @param mixed $value Value of the prefixed user field. 1277 * @param int $user_id User ID. 1278 */ 1145 1279 $value = apply_filters("edit_user_{$field}", $value, $user_id); 1146 1280 } 1147 1281 … … 1151 1285 $value = esc_attr($value); 1152 1286 } else if ( 'db' == $context ) { 1153 1287 if ( $prefixed ) { 1154 $value = apply_filters("pre_{$field}", $value); 1288 /** This filter is documented in wp-includes/post.php */ 1289 $value = apply_filters( "pre_{$field}", $value ); 1155 1290 } else { 1156 $value = apply_filters("pre_user_{$field}", $value); 1291 /** 1292 * Filter the value of a user field in the 'db' context. 1293 * 1294 * The dynamic portion of the hook name, $field, refers to the prefixed 1295 * user field being filtered, such as 'user_login', 'user_email', 1296 * 'first_name', etc. 1297 * 1298 * @since 2.9.0 1299 * 1300 * @param mixed $value Value of the prefixed user field. 1301 */ 1302 $value = apply_filters( "pre_user_{$field}", $value ); 1157 1303 } 1158 1304 } else { 1159 1305 // Use display filters by default. 1160 if ( $prefixed ) 1161 $value = apply_filters($field, $value, $user_id, $context); 1162 else 1306 if ( $prefixed ){ 1307 /** This filter is documented in wp-includes/post.php */ 1308 $value = apply_filters( $field, $value, $user_id, $context ); 1309 }else{ 1310 /** 1311 * Filter the value of a user field in a standard context. 1312 * 1313 * The dynamic portion of the hook name, $field, refers to the prefixed 1314 * user field being filtered, such as 'user_login', 'user_email', 1315 * 'first_name', etc. 1316 * 1317 * @since 2.9.0 1318 * 1319 * @param mixed $value The user object value to sanitize. 1320 * @param int $user_id User ID. 1321 * @param string $context The context to filter within. 1322 */ 1163 1323 $value = apply_filters("user_{$field}", $value, $user_id, $context); 1324 } 1164 1325 } 1165 1326 1166 1327 if ( 'user_url' == $field ) … … 1252 1413 function validate_username( $username ) { 1253 1414 $sanitized = sanitize_user( $username, true ); 1254 1415 $valid = ( $sanitized == $username ); 1416 /** 1417 * Filter whether the provided username is valid or not. 1418 * 1419 * @since 2.0.11 1420 * 1421 * @param bool $valid Whether username given is valid. 1422 * @param string $username The username to check. 1423 */ 1255 1424 return apply_filters( 'validate_username', $valid, $username ); 1256 1425 } 1257 1426 … … 1317 1486 } 1318 1487 1319 1488 $user_login = sanitize_user($user_login, true); 1320 $user_login = apply_filters('pre_user_login', $user_login); 1489 /** 1490 * Filter a username after it has been sanitized, but before 1491 * the user is created or updated. 1492 * 1493 * This hook is called before the user is created or updated. 1494 * 1495 * @since 2.0.11 1496 * 1497 * @param string $user_login The username after it has been sanitized. 1498 */ 1499 $user_login = apply_filters( 'pre_user_login', $user_login ); 1321 1500 1322 1501 //Remove any non-printable chars from the login string to see if we have ended up with an empty username 1323 1502 $user_login = trim($user_login); … … 1330 1509 1331 1510 if ( empty($user_nicename) ) 1332 1511 $user_nicename = sanitize_title( $user_login ); 1333 $user_nicename = apply_filters('pre_user_nicename', $user_nicename); 1512 1513 /** 1514 * Filter a user's nicename before the user is created or updated. 1515 * 1516 * This hook is called before the user is created or updated. 1517 * 1518 * @since 2.0.11 1519 * 1520 * @param string $user_nicename The user's nicename. 1521 */ 1522 $user_nicename = apply_filters( 'pre_user_nicename', $user_nicename ); 1334 1523 1335 1524 if ( empty($user_url) ) 1336 1525 $user_url = ''; 1337 $user_url = apply_filters('pre_user_url', $user_url); 1526 1527 /** 1528 * Filter a user's URL before the user is created or updated. 1529 * 1530 * @since 2.0.11 1531 * 1532 * @param string $user_url The user's URL. 1533 */ 1534 $user_url = apply_filters( 'pre_user_url', $user_url ); 1338 1535 1339 1536 if ( empty($user_email) ) 1340 1537 $user_email = ''; 1341 $user_email = apply_filters('pre_user_email', $user_email); 1538 1539 /** 1540 * Filter a user's email before the user is created or updated. 1541 * 1542 * @since 2.0.11 1543 * 1544 * @param string $user_email The user's email. 1545 */ 1546 $user_email = apply_filters( 'pre_user_email', $user_email ); 1342 1547 1343 1548 if ( !$update && ! defined( 'WP_IMPORTING' ) && email_exists($user_email) ) 1344 1549 return new WP_Error( 'existing_user_email', __( 'Sorry, that email address is already used!' ) ); 1345 1550 1346 1551 if ( empty($nickname) ) 1347 1552 $nickname = $user_login; 1348 $nickname = apply_filters('pre_user_nickname', $nickname); 1553 1554 /** 1555 * Filter a user's nickname before the user is created or updated. 1556 * 1557 * @since 2.0.11 1558 * 1559 * @param string $nickname The user's nickname. 1560 */ 1561 $nickname = apply_filters( 'pre_user_nickname', $nickname ); 1349 1562 1350 1563 if ( empty($first_name) ) 1351 1564 $first_name = ''; 1352 $first_name = apply_filters('pre_user_first_name', $first_name); 1565 1566 /** 1567 * Filter a user's first name before the user is created or updated. 1568 * 1569 * @since 2.0.11 1570 * 1571 * @param string $first_name The user's first name. 1572 */ 1573 $first_name = apply_filters( 'pre_user_first_name', $first_name ); 1353 1574 1354 1575 if ( empty($last_name) ) 1355 1576 $last_name = ''; 1356 $last_name = apply_filters('pre_user_last_name', $last_name); 1577 1578 /** 1579 * Filter a user's last name before the user is created or updated. 1580 * 1581 * @since 2.0.11 1582 * 1583 * @param string $last_name The user's last name. 1584 */ 1585 $last_name = apply_filters( 'pre_user_last_name', $last_name ); 1357 1586 1358 1587 if ( empty( $display_name ) ) { 1359 1588 if ( $update ) … … 1368 1597 else 1369 1598 $display_name = $user_login; 1370 1599 } 1600 1601 /** 1602 * Filter a user's display name before the user is created or updated. 1603 * 1604 * @since 2.0.11 1605 * 1606 * @param string $display_name The user's display name. 1607 */ 1371 1608 $display_name = apply_filters( 'pre_user_display_name', $display_name ); 1372 1609 1373 1610 if ( empty($description) ) 1374 1611 $description = ''; 1375 $description = apply_filters('pre_user_description', $description); 1612 1613 /** 1614 * Filter a user's description before the user is created or updated. 1615 * 1616 * @since 2.0.11 1617 * 1618 * @param string $description The user's description. 1619 */ 1620 $description = apply_filters( 'pre_user_description', $description ); 1376 1621 1377 1622 if ( empty($rich_editing) ) 1378 1623 $rich_editing = 'true'; … … 1431 1676 wp_cache_delete($user_id, 'users'); 1432 1677 wp_cache_delete($user_login, 'userlogins'); 1433 1678 1434 if ( $update ) 1679 if ( $update ) { 1680 /** 1681 * Fires immediately after an existing user is updated. 1682 * 1683 * @since 2.0.0 1684 * 1685 * @param int $user_id User ID. 1686 * @param object $old_user_data Object containing user's data prior to update. 1687 */ 1435 1688 do_action('profile_update', $user_id, $old_user_data); 1436 else 1437 do_action('user_register', $user_id); 1689 } else { 1690 /** 1691 * Fires immediately after a new user is registered. 1692 * 1693 * @since 1.5.2 1694 * 1695 * @param int $user_id User ID. 1696 */ 1697 do_action( 'user_register', $user_id ); 1698 } 1438 1699 1439 1700 return $user_id; 1440 1701 } … … 1643 1904 * @param string $new_pass New password for the user in plaintext 1644 1905 */ 1645 1906 function reset_password( $user, $new_pass ) { 1907 1908 /** 1909 * Fires before the user's password is reset. 1910 * 1911 * @since Unknown 1912 * 1913 * @param int $user_id User ID. 1914 * @param object $old_user_data User's data prior to update as a raw object. 1915 */ 1646 1916 do_action( 'password_reset', $user, $new_pass ); 1647 1917 1648 1918 wp_set_password( $new_pass, $user->ID ); … … 1662 1932 $errors = new WP_Error(); 1663 1933 1664 1934 $sanitized_user_login = sanitize_user( $user_login ); 1935 /** 1936 * Filter the email address of a user being registered. 1937 * 1938 * This hooks is triggered before the user is created. 1939 * 1940 * @since 2.1.0 1941 * 1942 * @param string $user_email The email of the new user. 1943 */ 1665 1944 $user_email = apply_filters( 'user_registration_email', $user_email ); 1666 1945 1667 1946 // Check the username … … 1684 1963 $errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) ); 1685 1964 } 1686 1965 1966 /** 1967 * FIRES when registration form data is submitted, and before the user has been created. 1968 * 1969 * @since 2.1.0 1970 * 1971 * @param string $sanitized_user_login The submitted username after being sanitized. 1972 * @param string $user_email The submitted email. 1973 * @param WP_Error $errors Contains any errors with the submitted username and 1974 * email (e.g. invalid, already exists). 1975 */ 1687 1976 do_action( 'register_post', $sanitized_user_login, $user_email, $errors ); 1688 1977 1978 /** 1979 * Filter the errors encountered when a new user is beng registerered. 1980 * 1981 * The filtered WP_Error object may, for example, contain errors for an invalid 1982 * or existing username or email. A WP_Error object should always returned, but 1983 * may or may not contain errors. 1984 * 1985 * If any errors are present in $errors, this will abort the user's registration. 1986 * 1987 * @since 2.1.0 1988 * 1989 * @param WP_Error $errors A WP_Error object containing any errors encountered 1990 * during registration. 1991 * @param string $sanitized_user_login User's username after it has been sanitized. 1992 * @param string $user_email User's email. 1993 */ 1689 1994 $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email ); 1690 1995 1691 1996 if ( $errors->get_error_code() )
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)