buddypress / BP-REST

A RESTful API, for BuddyPress
157 stars 38 forks source link

Allow additional profile fields to be included into the signup process #489

Closed imath closed 7 months ago

imath commented 1 year ago

I agree with this ticket, we should mimic what we are making available from front end from the BP REST API.

See: https://buddypress.trac.wordpress.org/ticket/8976

berzki commented 2 months ago

Hi @imath and @renatonascalves

I was looking to use the new signup feature through the REST API in BuddyPress 14 but I am unable to send certain data successfully. I have countries/areas already setup for a few years now and when I send "Sacramento, California, United States" it is taken as 3 values when it is just one. When the user activates the account, the field is blank. Hoping for a reply! Cheers.

renatonascalves commented 2 months ago

@berzki Are you using V1 or V2? Can you share the request?

berzki commented 2 months ago

@renatonascalves I am using the standard release version, so V1.

Field 2 is a checkbox field type. But this happens for any values with commas in them such as a location and that a user can select multiples of. This includes multi select field types.

Request:

{
    "context" : "edit",
    "user_login" : "mike",
    "user_email" : "mike@user.mail",
    "password"   : "password",
    "signup_field_data": [
        {
            "field_id": "1",
            "value": "Mike"
        },
        {
            "field_id": "2",
            "value": "Sacramento, California, United States"
        }
    ]
}

Response:

[
    {
        "id": 200,
        "user_login": "mike",
        "registered": "2024-10-03T00:36:33",
        "registered_gmt": "2024-10-03T00:36:33",
        "user_email": "mike@user.mail",
        "date_sent": "2024-10-03T00:36:33",
        "date_sent_gmt": "2024-10-03T00:36:33",
        "count_sent": 0,
        "meta": {
            "field_1": "Mike",
            "field_1_visibility": "public",
            "field_2": [
                "Sacramento",
                "California",
                "United States"
            ],
            "field_2_visibility": "public",
            "profile_field_ids": "1,2",
            "sent_date": "0000-00-00 00:00:00",
            "count_sent": 0
        },
        "_links": {
            "self": [
                {
                    "href": "https://www.website.com/wp-json/buddypress/v1/signup/200"
                }
            ],
            "collection": [
                {
                    "href": "https://www.website.com/wp-json/buddypress/v1/signup/"
                }
            ]
        }
    }
]
renatonascalves commented 2 months ago

@berzki That's helpful. Can you also share the type of the field? Is it a text field? A multi-select one?

berzki commented 2 months ago

@renatonascalves The field is a checkbox type. I have tested it with a multi select box too and the result was the same.

berzki commented 1 month ago

Hi @imath and @renatonascalves

This appears to be by design? Meaning plugin users who have existing values with commas in them and are in checkboxes and multi select boxes cannot use the new signup feature. I am no expert, but I assume accepting them as arrays would solve this issue?