Ticket #25533: 25533.4.diff
| File 25533.4.diff, 16.7 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.1 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 $credentials { 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 * Fires after the user has successfully logged in. 91 * 92 * @since 1.5.0 93 * 94 * @param string $user_login Username. 95 * @param WP_User $user WP_User object of the logged-in user. 96 */ 97 do_action( 'wp_login', $user->user_login, $user ); 65 98 return $user; 66 99 } 67 100 … … 92 125 if ( !$user ) 93 126 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 127 95 $user = apply_filters('wp_authenticate_user', $user, $password); 128 /** 129 * Filter whether the given user can be authenticated with the provided $password. 130 * 131 * @since 2.5.0 132 * 133 * @param WP_User|WP_Error $user WP_User object or WP_Error object if a previous 134 * callback failed authentication. 135 * @param string $password The password to check against the user. 136 */ 137 $user = apply_filters( 'wp_authenticate_user', $user, $password ); 96 138 if ( is_wp_error($user) ) 97 139 return $user; 98 140 … … 138 180 */ 139 181 function wp_authenticate_spam_check( $user ) { 140 182 if ( $user && is_a( $user, 'WP_User' ) && is_multisite() ) { 183 /** 184 * Filter whether the user has been marked as a spammer. 185 * 186 * @since 3.7.0 187 * 188 * @param bool $spammed Whether the user is considered spam. 189 * @param WP_User $user The user to check against. 190 */ 141 191 $spammed = apply_filters( 'check_is_user_spammed', is_user_spammy(), $user ); 142 192 143 193 if ( $spammed ) … … 162 212 163 213 $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); 164 214 165 return apply_filters('get_usernumposts', $count, $userid); 215 /** 216 * Filter the number of posts a user has written. 217 * 218 * @since 2.7.0 219 * 220 * @param int $count The user's post count. 221 * @param int $userid User ID. 222 */ 223 return apply_filters( 'get_usernumposts', $count, $userid ); 166 224 } 167 225 168 226 /** … … 258 316 else 259 317 $result = false; 260 318 261 return apply_filters("get_user_option_{$option}", $result, $option, $user); 319 /** 320 * Filter a specific user option value. 321 * 322 * The dynamic portion of the hook name, $option, refers to the user option name. 323 * 324 * @since 2.5.0 325 * 326 * @param mixed $result Value for the user's option. 327 * @param string $option Name of the option being retrieved. 328 * @param WP_User $user WP_User object of the user whose option is being retrieved. 329 */ 330 return apply_filters( "get_user_option_{$option}", $result, $option, $user ); 262 331 } 263 332 264 333 /** … … 496 565 $search_columns = array('user_login', 'user_nicename'); 497 566 } 498 567 568 /** 569 * Filter the columns to search in a WP_User_Query search. 570 * 571 * The default columns depend on the search term, and include 'user_email', 572 * 'user_login', 'ID', 'user_url', and 'user_nicename'. 573 * 574 * @since 3.6.0 575 * 576 * @param array $search_columns Array of column names to be searched. 577 * @param string $search The text being searched. 578 * @param WP_User_Query $this The current WP_User_Query instance. 579 */ 499 580 $search_columns = apply_filters( 'user_search_columns', $search_columns, $search, $this ); 500 581 501 582 $this->query_where .= $this->get_search_sql( $search, $search_columns, $wild ); … … 548 629 $this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)"; 549 630 } 550 631 632 /** 633 * Fires after the WP_User_Query has been parsed, and before 634 * the query is executed. 635 * 636 * The passed WP_User_Query object contains SQL parts formed 637 * from parsing the given query. 638 * 639 * @since 3.1.0 640 * 641 * @param WP_User_Query $this The current WP_User_Query instance, 642 * passed by reference. 643 */ 551 644 do_action_ref_array( 'pre_user_query', array( &$this ) ); 552 645 } 553 646 … … 568 661 $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 569 662 } 570 663 664 /** 665 * Filter SELECT_FOUND_ROWS value for the current WP_User_Query instance. 666 * 667 * @since 3.2.0 668 * 669 * @global wpdb $wpdb WordPress database object. 670 * 671 * @param string $sql The SELECT_FOUND_ROWS() value for the current WP_User_Query. 672 */ 571 673 if ( isset( $qv['count_total'] ) && $qv['count_total'] ) 572 674 $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); 573 675 … … 776 878 } 777 879 } 778 880 881 /** 882 * Filter the list of blogs a user belongs to. 883 * 884 * @since MU 885 * 886 * @param array $blogs An array of blog objects belonging to the user. 887 * @param int $user_id User ID. 888 * @param bool $all Whether the returned blogs array should contain all blogs, including 889 * those marked 'deleted', 'archived', or 'spam'. Default false. 890 */ 779 891 return apply_filters( 'get_blogs_of_user', $blogs, $user_id, $all ); 780 892 } 781 893 … … 1095 1207 $output .= "</select>"; 1096 1208 } 1097 1209 1098 $output = apply_filters('wp_dropdown_users', $output); 1210 /** 1211 * Filter the wp_dropdown_users() HTML output. 1212 * 1213 * @since 2.3.0 1214 * 1215 * @param string $output HTML output generated by wp_dropdown_users(). 1216 */ 1217 $output = apply_filters( 'wp_dropdown_users', $output ); 1099 1218 1100 1219 if ( $echo ) 1101 1220 echo $output; … … 1140 1259 1141 1260 if ( 'edit' == $context ) { 1142 1261 if ( $prefixed ) { 1143 $value = apply_filters("edit_{$field}", $value, $user_id); 1262 /** This filter is documented in wp-includes/post.php */ 1263 $value = apply_filters( "edit_{$field}", $value, $user_id ); 1144 1264 } else { 1145 $value = apply_filters("edit_user_{$field}", $value, $user_id); 1265 /** 1266 * Filter a user field value in the 'edit' context. 1267 * 1268 * The dynamic portion of the hook name, $field, refers to the prefixed user 1269 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc. 1270 * 1271 * @since 2.9.0 1272 * 1273 * @param mixed $value Value of the prefixed user field. 1274 * @param int $user_id User ID. 1275 */ 1276 $value = apply_filters( "edit_user_{$field}", $value, $user_id ); 1146 1277 } 1147 1278 1148 1279 if ( 'description' == $field ) … … 1151 1282 $value = esc_attr($value); 1152 1283 } else if ( 'db' == $context ) { 1153 1284 if ( $prefixed ) { 1154 $value = apply_filters("pre_{$field}", $value); 1285 /** This filter is documented in wp-includes/post.php */ 1286 $value = apply_filters( "pre_{$field}", $value ); 1155 1287 } else { 1156 $value = apply_filters("pre_user_{$field}", $value); 1288 /** 1289 * Filter the value of a user field in the 'db' context. 1290 * 1291 * The dynamic portion of the hook name, $field, refers to the prefixed user 1292 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc. 1293 * 1294 * @since 2.9.0 1295 * 1296 * @param mixed $value Value of the prefixed user field. 1297 */ 1298 $value = apply_filters( "pre_user_{$field}", $value ); 1157 1299 } 1158 1300 } else { 1159 1301 // Use display filters by default. 1160 if ( $prefixed ) 1161 $value = apply_filters($field, $value, $user_id, $context); 1162 else 1163 $value = apply_filters("user_{$field}", $value, $user_id, $context); 1302 if ( $prefixed ){ 1303 /** This filter is documented in wp-includes/post.php */ 1304 $value = apply_filters( $field, $value, $user_id, $context ); 1305 }else{ 1306 /** 1307 * Filter the value of a user field in a standard context. 1308 * 1309 * The dynamic portion of the hook name, $field, refers to the prefixed user 1310 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc. 1311 * 1312 * @since 2.9.0 1313 * 1314 * @param mixed $value The user object value to sanitize. 1315 * @param int $user_id User ID. 1316 * @param string $context The context to filter within. 1317 */ 1318 $value = apply_filters( "user_{$field}", $value, $user_id, $context ); 1319 } 1164 1320 } 1165 1321 1166 1322 if ( 'user_url' == $field ) … … 1252 1408 function validate_username( $username ) { 1253 1409 $sanitized = sanitize_user( $username, true ); 1254 1410 $valid = ( $sanitized == $username ); 1411 /** 1412 * Filter whether the provided username is valid or not. 1413 * 1414 * @since 2.0.1 1415 * 1416 * @param bool $valid Whether username given is valid. Default true. 1417 * @param string $username The username to check. 1418 */ 1255 1419 return apply_filters( 'validate_username', $valid, $username ); 1256 1420 } 1257 1421 … … 1317 1481 } 1318 1482 1319 1483 $user_login = sanitize_user($user_login, true); 1320 $user_login = apply_filters('pre_user_login', $user_login); 1484 /** 1485 * Filter a username after it has been sanitized. 1486 * 1487 * This filter is called before the user is created or updated. 1488 * 1489 * @since 2.0.3 1490 * 1491 * @param string $user_login The username after it has been sanitized. 1492 */ 1493 $user_login = apply_filters( 'pre_user_login', $user_login ); 1321 1494 1322 1495 //Remove any non-printable chars from the login string to see if we have ended up with an empty username 1323 1496 $user_login = trim($user_login); … … 1330 1503 1331 1504 if ( empty($user_nicename) ) 1332 1505 $user_nicename = sanitize_title( $user_login ); 1333 $user_nicename = apply_filters('pre_user_nicename', $user_nicename); 1506 /** 1507 * Filter a user's nicename before the user is created or updated. 1508 * 1509 * @since 2.0.3 1510 * 1511 * @param string $user_nicename The user's nicename. 1512 */ 1513 $user_nicename = apply_filters( 'pre_user_nicename', $user_nicename ); 1334 1514 1335 1515 if ( empty($user_url) ) 1336 1516 $user_url = ''; 1337 $user_url = apply_filters('pre_user_url', $user_url); 1517 /** 1518 * Filter a user's URL before the user is created or updated. 1519 * 1520 * @since 2.0.3 1521 * 1522 * @param string $user_url The user's URL. 1523 */ 1524 $user_url = apply_filters( 'pre_user_url', $user_url ); 1338 1525 1339 1526 if ( empty($user_email) ) 1340 1527 $user_email = ''; 1341 $user_email = apply_filters('pre_user_email', $user_email); 1528 /** 1529 * Filter a user's email before the user is created or updated. 1530 * 1531 * @since 2.0.3 1532 * 1533 * @param string $user_email The user's email. 1534 */ 1535 $user_email = apply_filters( 'pre_user_email', $user_email ); 1342 1536 1343 1537 if ( !$update && ! defined( 'WP_IMPORTING' ) && email_exists($user_email) ) 1344 1538 return new WP_Error( 'existing_user_email', __( 'Sorry, that email address is already used!' ) ); … … 1345 1539 1346 1540 if ( empty($nickname) ) 1347 1541 $nickname = $user_login; 1348 $nickname = apply_filters('pre_user_nickname', $nickname); 1542 /** 1543 * Filter a user's nickname before the user is created or updated. 1544 * 1545 * @since 2.0.3 1546 * 1547 * @param string $nickname The user's nickname. 1548 */ 1549 $nickname = apply_filters( 'pre_user_nickname', $nickname ); 1349 1550 1350 1551 if ( empty($first_name) ) 1351 1552 $first_name = ''; 1352 $first_name = apply_filters('pre_user_first_name', $first_name); 1553 /** 1554 * Filter a user's first name before the user is created or updated. 1555 * 1556 * @since 2.0.3 1557 * 1558 * @param string $first_name The user's first name. 1559 */ 1560 $first_name = apply_filters( 'pre_user_first_name', $first_name ); 1353 1561 1354 1562 if ( empty($last_name) ) 1355 1563 $last_name = ''; 1356 $last_name = apply_filters('pre_user_last_name', $last_name); 1564 /** 1565 * Filter a user's last name before the user is created or updated. 1566 * 1567 * @since 2.0.3 1568 * 1569 * @param string $last_name The user's last name. 1570 */ 1571 $last_name = apply_filters( 'pre_user_last_name', $last_name ); 1357 1572 1358 1573 if ( empty( $display_name ) ) { 1359 1574 if ( $update ) … … 1368 1583 else 1369 1584 $display_name = $user_login; 1370 1585 } 1586 /** 1587 * Filter a user's display name before the user is created or updated. 1588 * 1589 * @since 2.0.3 1590 * 1591 * @param string $display_name The user's display name. 1592 */ 1371 1593 $display_name = apply_filters( 'pre_user_display_name', $display_name ); 1372 1594 1373 1595 if ( empty($description) ) 1374 1596 $description = ''; 1375 $description = apply_filters('pre_user_description', $description); 1597 /** 1598 * Filter a user's description before the user is created or updated. 1599 * 1600 * @since 2.0.3 1601 * 1602 * @param string $description The user's description. 1603 */ 1604 $description = apply_filters( 'pre_user_description', $description ); 1376 1605 1377 1606 if ( empty($rich_editing) ) 1378 1607 $rich_editing = 'true'; … … 1431 1660 wp_cache_delete($user_id, 'users'); 1432 1661 wp_cache_delete($user_login, 'userlogins'); 1433 1662 1434 if ( $update ) 1435 do_action('profile_update', $user_id, $old_user_data); 1436 else 1437 do_action('user_register', $user_id); 1663 if ( $update ) { 1664 /** 1665 * Fires immediately after an existing user is updated. 1666 * 1667 * @since 2.0.0 1668 * 1669 * @param int $user_id User ID. 1670 * @param object $old_user_data Object containing user's data prior to update. 1671 */ 1672 do_action( 'profile_update', $user_id, $old_user_data ); 1673 } else { 1674 /** 1675 * Fires immediately after a new user is registered. 1676 * 1677 * @since 1.5.0 1678 * 1679 * @param int $user_id User ID. 1680 */ 1681 do_action( 'user_register', $user_id ); 1682 } 1438 1683 1439 1684 return $user_id; 1440 1685 } … … 1643 1888 * @param string $new_pass New password for the user in plaintext 1644 1889 */ 1645 1890 function reset_password( $user, $new_pass ) { 1891 /** 1892 * Fires before the user's password is reset. 1893 * 1894 * @since 1.5.0 1895 * 1896 * @param object $user The user. 1897 * @param string $new_pass New user password. 1898 */ 1646 1899 do_action( 'password_reset', $user, $new_pass ); 1647 1900 1648 1901 wp_set_password( $new_pass, $user->ID ); … … 1662 1915 $errors = new WP_Error(); 1663 1916 1664 1917 $sanitized_user_login = sanitize_user( $user_login ); 1918 /** 1919 * Filter the email address of a user being registered. 1920 * 1921 * @since 2.1.0 1922 * 1923 * @param string $user_email The email address of the new user. 1924 */ 1665 1925 $user_email = apply_filters( 'user_registration_email', $user_email ); 1666 1926 1667 1927 // Check the username … … 1684 1944 $errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) ); 1685 1945 } 1686 1946 1947 /** 1948 * Fires when submitting registration form data, before the user is created. 1949 * 1950 * @since 2.1.0 1951 * 1952 * @param string $sanitized_user_login The submitted username after being sanitized. 1953 * @param string $user_email The submitted email. 1954 * @param WP_Error $errors Contains any errors with submitted username and email, 1955 * e.g., an empty field, an invalid username or email, 1956 * or an existing username or email. 1957 */ 1687 1958 do_action( 'register_post', $sanitized_user_login, $user_email, $errors ); 1688 1959 1960 /** 1961 * Filter the errors encountered when a new user is being registered. 1962 * 1963 * The filtered WP_Error object may, for example, contain errors for an invalid 1964 * or existing username or email address. A WP_Error object should always returned, 1965 * but may or may not contain errors. 1966 * 1967 * If any errors are present in $errors, this will abort the user's registration. 1968 * 1969 * @since 2.1.0 1970 * 1971 * @param WP_Error $errors A WP_Error object containing any errors encountered 1972 * during registration. 1973 * @param string $sanitized_user_login User's username after it has been sanitized. 1974 * @param string $user_email User's email. 1975 */ 1689 1976 $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email ); 1690 1977 1691 1978 if ( $errors->get_error_code() )
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)