Changeset 12254 for sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/profile-helpers.php
- Timestamp:
- 11/21/2022 04:19:12 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/profile-helpers.php
r12122 r12254 2 2 3 3 /* 4 * These functions provide a simple interface for other plugins to add/remove badges and activity entries from 5 * profiles.w.org. 4 * These functions provide a simple interface for other plugins to modify WordPress.org Profile data, such as badges, activity entries, and xProfile fields. 6 5 * 7 * See `api.w.org/includes/profiles/profiles.php` for a similar function that is tailored to the API.6 * See `api.w.org/includes/profiles/profiles.php` for a similar badge function that is tailored to the API. 8 7 */ 9 8 10 9 namespace WordPressdotorg\Profiles; 11 use WP_Error ;10 use WP_Error, WP_User; 12 11 13 12 /** … … 49 48 'user' => $user, 50 49 'args' => $args, 50 ] ); 51 52 return ( 200 === wp_remote_retrieve_response_code( $request ) ); 53 } 54 55 /** 56 * Update a BuddyPress profile field with a value. 57 * 58 * @param $field string The profile field name to update. 59 * @param $value mixed The value to update it to. 60 * @param $user int|WP_User The user object or user ID to update. 61 * @return bool 62 */ 63 function update_profile( $field, $value, $user ) { 64 $request = api( [ 65 'action' => 'wporg_update_profile', 66 'user' => $user instanceOf WP_User ? $user->ID : $user, 67 'fields' => [ 68 $field => $value 69 ], 51 70 ] ); 52 71
Note: See TracChangeset
for help on using the changeset viewer.