[buddypress-trac] [BuddyPress Trac] #7162: xprofile field support for WordPress Profile Fields

buddypress-trac noreply at wordpress.org
Tue Feb 2 21:24:03 UTC 2021


#7162: xprofile field support for WordPress Profile Fields
----------------------------------------+---------------------
 Reporter:  DJPaul                      |       Owner:  (none)
     Type:  feature request             |      Status:  new
 Priority:  strategic                   |   Milestone:  8.0.0
Component:  Extended Profile            |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |
----------------------------------------+---------------------
Changes (by imath):

 * keywords:  needs-patch => has-patch needs-unit-tests


Comment:

 Hi!

 7162.patch is my suggestion to add this feature to BP xProfiles. I've used
 @DJPaul's
 [https://github.com/paulgibbs/BuddyPress/commit/4be901cbf0c4c23cce74de221f973c001ccfeb19
 initial work] to start including the `wp-biography` field type to the
 WordPress fields managed from the site's front-end thanks to the xProfile
 component.

 I believe I've found a way to avoid mirroring WordPress data into the
 xProfile data table: in `BP_XProfile_ProfileData::get_data_for_user()` if
 the field value is not found into the cache, there's a fallback to use an
 empty value to "avoid future cache misses". In this part of the code I'm
 checking the User Meta cache or the displayed WP User one for the
 `user_url` (this information is stored into the `$wpdb->users` table) to
 include the field value of the WordPress field.

 [[Image(https://cldup.com/cG7pWYf025.png)]]

 Here's a screenshot about the `wp-textbox` field type. This type is a bit
 more elaborated than the `wp-biography` one as when you select it, you
 need to select one of the available info you want to display from the
 complementary metabox.

 [[Image(https://cldup.com/Qff3BsYNRS.png)]]

 The link in this case is made using an xProfile field meta. @netweb I
 believe User contact methods should be included if a Plugin adds some (I
 haven't tested yet).

 I added some specific behavior for WordPress fields, it doesn't support:
 - the "require" feature (as this information is not required by WordPress)
 - the custom visibility, as these fields are public (eg the description
 can be seen into the Author WP template)
 - the "autolink" feature. If it doesn't make sense to have this feature
 for the `wp-biography` field, it might have more sense to have it the
 first name/last name. Maybe this is something we can improve later :)

 [[Image(https://cldup.com/EYQPPV7m1m.png)]]

 To save field values I think we should use `wp_update_user()` as it
 handles `$wpdb->users` fields as well as `$wpdb->usermeta` fields. To
 avoid running this function more than one once, I'm using the
 `buddypress()->displayed_user` global object to keep a track of edited
 WordPress fields and only update fields once we're out of the edit loop.

 @vapvarun About the `user_nicename` field, I believe it's a sensitive case
 because we are using it to build the user domain. So I believe we should
 avoid editing it too much. I'm fine with exploring a new signup field to
 allow users to have a login that doesn't appear into the URL (to improve
 security) asking new users to define their domain but this probably needs
 to be discussed into another ticket.

 Feedbacks welcome ❤️

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


More information about the buddypress-trac mailing list