Tagged: code, registration, user role
Hello
I have a question about using this code here:
https://buddydev.com/assign-user-roles-based-on-buddypress-profile-field-data-on-user-registration/On line 19, in red, it says “Membership Type”. The comment says “Change this with actual field id or Name”.
My question is, what is the field “name”: is it the human readable name I set when creating a field in the wordpress dashboard -> users -> profile field, such as “Author Bio” or “Home Town”, or is the machine code ID found in the HTML? For example, I have a field called “Member Type” but when you mouse over the “edit” button in the dashboard, it says “field_id=2”, and when I right click and select “inspect”, it says “id=”field_2” name=”field_2. So can I use the human readable format field name, or should I use the machine allocated “name”, which in this case, is “field_2”?
I’ve already tested it with the human readable format field name of “Member Type” and it works but I just wanted to make sure it wasn’t a coincidence that it worked and confirm the correct use of the code.
Thank you.
The topic ‘ [Resolved] How to use code for allocating user role upon registration’ is closed to new replies.