[buddypress-trac] [BuddyPress Trac] #7658: Use WP functions to retrieve current user ID.

buddypress-trac noreply at wordpress.org
Thu Jan 18 16:26:39 UTC 2018


#7658: Use WP functions to retrieve current user ID.
--------------------------+------------------------------
 Reporter:  dcavins       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Core          |     Version:  2.9.2
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by dcavins):

 Unless I'm missing something, adding a magic getter is going to require
 some new architecture, because `$bp->loggedin_user` is a `stdClass`. As I
 understand it, we'd have to make `loggedin_user` a first-class class to
 add methods. Is that correct?

 If so, it seems like more duplication of what WP is already doing with the
 current user. Most of the current user stuff could be switched to this
 style:


 {{{
 function bp_loggedin_user_id() {
         /**
          * Filters the ID of the currently logged-in user.
          *
          * @since 1.0.0
          *
          * @param int $id ID of the currently logged-in user.
          */
         return (int) apply_filters( 'bp_loggedin_user_id',
 get_current_user_id() );
 }
 }}}

 Similarly, to fetch the current user's display name (fullname), we could
 use `get_the_author_meta( 'display_name', get_current_user_id() )`. (I'm
 assuming that these values are cached by WP.)

 The exception I believe is the domain, which is calculated by BP.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7658#comment:6>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list