WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/09/2014 03:22:13 PM (6 years ago)
Author:
nacin
Message:

Allow for custom authentication handlers for all requests.

Turn the logic used by wp_get_current_user() into a determine_current_user filter.

props rmccue.
fixes #26706.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r27149 r27484  
    9898    }
    9999
    100     if ( ! $user = wp_validate_auth_cookie() ) {
    101          if ( is_blog_admin() || is_network_admin() || empty( $_COOKIE[LOGGED_IN_COOKIE] ) || !$user = wp_validate_auth_cookie( $_COOKIE[LOGGED_IN_COOKIE], 'logged_in' ) ) {
    102             wp_set_current_user( 0 );
    103             return false;
    104          }
    105     }
    106 
    107     wp_set_current_user( $user );
     100    /**
     101     * Determine the current user based on request data.
     102     *
     103     * The default filters use this to determine the current user from the
     104     * request's cookies, if available.
     105     *
     106     * @since 3.9.0
     107     *
     108     * @param int|boolean $user_id User ID if determined, or false otherwise.
     109     */
     110    $user_id = apply_filters( 'determine_current_user', false );
     111    if ( ! $user_id ) {
     112        wp_set_current_user( 0 );
     113        return false;
     114    }
     115
     116    wp_set_current_user( $user_id );
    108117}
    109118endif;
Note: See TracChangeset for help on using the changeset viewer.