Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/25/2018 07:44:54 PM (7 years ago)
Author:
dcavins
Message:

Use WP functions to retrieve user data.

Use WP functions to retrieve user name, display name, nicename, and email.

Switch functions like bp_core_get_username() to use native WordPress functions. This also removes the need for maintaining redundant cached items, like caching individual usernames, and instead relies upon WP's userdata cache.

Props dcavins, djpaul.

Fixes #7661.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-cache.php

    r11352 r11818  
    189189add_action( 'xprofile_group_after_delete', 'xprofile_clear_profile_groups_object_cache' );
    190190add_action( 'xprofile_group_after_save',   'xprofile_clear_profile_groups_object_cache' );
    191 
    192 /**
    193  * Clear cached XProfile fullname data for user.
    194  *
    195  * @since 2.1.0
    196  *
    197  * @param int $user_id ID of user whose fullname cache to delete.
    198  */
    199 function xprofile_clear_profile_data_object_cache( $user_id = 0 ) {
    200     wp_cache_delete( 'bp_user_fullname_' . $user_id, 'bp' );
    201 }
    202 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' );
    203 
    204 /**
    205  * Clear the fullname cache when field 1 is updated.
    206  *
    207  * The xprofile_clear_profile_data_object_cache() will make this redundant in most
    208  * cases, except where the field is updated directly with xprofile_set_field_data().
    209  *
    210  * @since 2.0.0
    211  *
    212  * @param object $data Data object to clear.
    213  */
    214 function xprofile_clear_fullname_cache_on_profile_field_edit( $data ) {
    215     if ( 1 == $data->field_id ) {
    216         wp_cache_delete( 'bp_user_fullname_' . $data->user_id, 'bp' );
    217     }
    218 }
    219 add_action( 'xprofile_data_after_save', 'xprofile_clear_fullname_cache_on_profile_field_edit' );
    220191
    221192/**
Note: See TracChangeset for help on using the changeset viewer.