Making WordPress.org


Ignore:
Timestamp:
03/11/2016 11:53:09 PM (9 years ago)
Author:
iandunn
Message:

WordCamp.org: Centralize user fetching functionality.

Previously wordcamp-participation-notifier and wc-post-types were using slightly different code to get the same data, which resulted in a bug where wc-post-types would find the user, but wordcamp-participation-notifier wouldn't. That led to some profile badges being removed when the speaker/organizer post was updated, because the notifier would think the username was removed from the field, and send a command to remove the badge.

Because the two plugins are interdependent, they need to use a common function to guarantee identical results.

get_saved_wporg_user_id() doesn't need to use the new function, because tix_username is always set from user_login, rather than being entered as user-input.

See #977

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/helper-functions.php

    r2418 r2743  
    127127    return isset( $flags[ $flag ] );
    128128}
     129
     130/**
     131 * Get a user by the username or nicename
     132 *
     133 * Note: This intentionally doesn't lookup users by the display name or nickname, because those can be set by the
     134 * user, which could result in false-positive matches.
     135 *
     136 * @param string $name
     137 *
     138 * @return false|WP_User
     139 */
     140function wcorg_get_user_by_canonical_names( $name ) {
     141    if ( ! $user = get_user_by( 'login', $name ) ) {    // user_login
     142        $user = get_user_by( 'slug', $name );           // user_nicename
     143    }
     144
     145    return $user;
     146}
Note: See TracChangeset for help on using the changeset viewer.