kinoli / groupie

Assign users to specific user groups upon registration. Especially useful for front-end signup forms.
Other
3 stars 0 forks source link

Registration Error #7

Closed bfjare closed 4 years ago

bfjare commented 4 years ago

Getting this error when registering.

array_intersect(): Expected parameter 2 to be an array, string given

If I remove the following input it works fine.

<input id="groups" type="hidden" name="groups[]" value="XXX">

I can also verify that the all groups are selected in the plugin

kinoli commented 4 years ago

Can you show me what your frontend field looks like?

kinoli commented 4 years ago

I've updated the readme to explain more about the groups usage on the frontend. Maybe that will help you.

bfjare commented 4 years ago

Here is the form

<form method="post" accept-charset="UTF-8">
    {{ csrfInput() }}
    {{ actionInput('users/save-user') }}
    {{ redirectInput('events/login') }}

    <input type="hidden" name="groups[]" value="17">

    {% macro errorList(errors) %}
        {% if errors %}
            <ul class="errors">
                {% for error in errors %}
                    <li>{{ error }}</li>
                {% endfor %}
            </ul>
        {% endif %}
    {% endmacro %}

    <label for="firstName">First Name</label>
    <input id="firstName" type="text" name="firstName"
        {%- if user is defined %} value="{{ user.firstName }}"{% endif -%}>

    <label for="lastName">LastName</label>
    <input id="lastName" type="text" name="lastName"
        {%- if user is defined %} value="{{ user.lastName }}"{% endif -%}>  

    <label for="username">Username</label>
    <input id="username" type="text" name="username"
        {%- if user is defined %} value="{{ user.username }}"{% endif -%}>

    {% if user is defined %}
        {{ _self.errorList(user.getErrors('username')) }}
    {% endif %}

    <label for="email">Email</label>
    <input id="email" type="text" name="email"
        {%- if user is defined %} value="{{ user.email }}"{% endif %}>

    {% if user is defined %}
        {{ _self.errorList(user.getErrors('email')) }}
    {% endif %}

    <label for="password">Password</label>
    <input id="password" type="password" name="password">

    {% if user is defined %}
        {{ _self.errorList(user.getErrors('password')) }}
    {% endif %}

    <input type="submit" value="Register">
</form>
kinoli commented 4 years ago

I did some testing and noticed the "all" option was causing issues when checked. This might be due to a recent CraftCMS update. I removed the selection for "All" groups. So you may need to reselect the groups you want to be able to assign users to in your forms. Go to the Groupie settings in the plugins page to do this. I just pushed an update for this, but if you don't have the update yet, you can test it on your end by deselecting the "all" option and selecting the individual groups you want to allow.