0

Can't seem to figure out how to add members via Channel Form to a VMG Chosen Member field.

Members need to be able to sign up for a session of their choosing on the front-end and be associated with that particular session in the CP.

There isn't any documentation on the vmg_chosen_member git page other than how to format/style the field if you're using {field:session-attendees}.

Ideally, I would pass the logged in member_id via a text input field like so:

{exp:channel:form channel="sessions" entry_id="{last_segment}" id="session-registration" class="session-form" return="url/success"}

<input name="session-attendees" type="text" value="{member_id}" />

<input type="submit" value="Register for this session" />

{/exp:channel:form}

But that doesn't work.

I don't want to use {field:session-attendees} because the member signing up for a session does not need to see the other members signed up.

What's the proper way to add members to a chosen member field via Channel Form?

1 Answer 1

1

If you're wanting to pass in a member_id to a VMG Chosen Member field, you'll need to pass it in as an array with a single member_id. The following should work for you, but let me know if you still have issues!

{exp:channel:form channel="sessions" entry_id="{last_segment}" id="session-registration" class="session-form" return="url/success"}

<input name="field_id_1[]" type="text" value="{member_id}" />

<input type="submit" value="Register for this session" />

{/exp:channel:form}

(replace field_id_1[] with the ID of your VMG Chosen Member field)

1
  • Thank you! I didn't include this in the original question, but I also needed to maintain the previous users who were registered for the session, and implementing your method (which worked) removed the previous registrants. To get around this, I added additional hidden fields with the previous member_ids to the form (input via stash variable), so when a new member signs up, it's like they're all signing up again. There's probably a more efficient way to do this, but it works as there is a limit of 6 registrants per session. Thanks, again.
    – Chris Bain
    Commented Mar 9, 2016 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.