Three new endpoints have been added in the JSON API User Plus plugin for BuddyPress Groups component REST JSON API to get, update and delete groups meta. This would add missing endpoints for the groups meta data management via REST API and mobile app. Both Update and Delete group meta endpoints have admin access check. Get endpoint has check that only members or admins can access the data. Only public groups are meta is available fro all users.
Here are the new endpoints:
1. groups_get_groupmeta
Get a piece of group metadata.
Parameters
- key – get API key from Settings > User Plus
- ‘group_id’ required. (int) ID of the group.
- cookie – required. if group is not public, user should be member, mod or admin of the group.
- ‘meta_key’ Optional. The meta key.
- single — Optional. If true, return only the first value of the specified meta_key. This parameter has no effect if meta_key is empty.
Return
(mixed) Metadata value.
2. groups_update_groupmeta
Parameters
- key – get API key from Settings > User Plus
- group_id required. (int) ID of the group
- cookie – required. admin of the group.
- meta_key required. The meta key.
- meta_value — required. The meta value.
Return
(bool|int) Returns false on failure. On successful update of existing metadata, returns true. On successful creation of new metadata, returns the integer ID of the new metadata row.
3. groups_delete_groupmeta
Delete metadata for a group.
Parameters
- key – get API key from Settings > User Plus
- ‘group_id’ required. (int) ID of the group.
- cookie – required. admin of the group.
- meta_key — Optional. The key of the row to delete.
- meta_value — Optional. Metadata value. If specified, only delete metadata entries with this value.
- delete_all — Optional. If true, delete matching metadata entries for all groups. Otherwise, only delete matching metadata entries for the specified group. Default: false.
Return
(bool) True on success, false on failure.