Support » Plugin: LifterLMS » Select multiple in Lifterlms Registration form

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Natalie

    (@nrherron)

    Hi @hamlet237,

    I’m sorry you’re having this issue!

    Would you mind sharing the code you’re modified for custom registration so we can take a look at why could be causing this issue?

    You can share code with this method: https://wordpress.org/support/forum-user-guide/faq/#i-need-to-post-code-is-that-okay

    We’re happy to take a look and get this solved for you!

    Let us know if you have any additional questions!

    Thanks and take care,

    hamlet237

    (@hamlet237)

    Thank you Natalie. This is the code: https://pastebin.com/GCeYu55y

    I´m working in a class function so please note the hooks with array(&$this,… added.

    The problem happens with $user_diseases array which loads a multiple select tag.

    Thanks in advance!

    Plugin Support Natalie

    (@nrherron)

    Hi @hamlet237,

    I apologize for the delay in response.

    Also, I believe I might have misunderstood your question initially.

    Just to clarify you’re wanting to allow the user the ability to select more than one option from the dropdown menu? If this is the case, this code won’t do that. Creating a multiple select is a big more involved. You would want to use something like this:

         ?><form action="c3.php" method="post">
      <select name="ary[]" multiple="multiple">
        <option value="Option 1" >Option 1</option>
        <option value="Option 2">Option 2</option>
        <option value="Option 3">Option 3</option>
        <option value="Option 4">Option 4</option>
        <option value="Option 5">Option 5</option>
      </select>
      <input type="submit">
    </form><?php
    
    $values = $_POST['ary'];
    
    foreach ($values as $a){
        echo $a;
    }

    (This is just an example, you’d have to format it!)

    With this type of PHP select multiple you would have to have the user hold down control/command to select more than one.

    The select box you’re working with here just allows you to provide multiple options, where the user can pick one.

    The easiest method might just be to have this be text input box.

    I apologize for the confusion here!

    Please let us know if you have further questions!

    Thanks and take care,

    Hi Natalie.
    As you can see in the code I´ve paste for you between lines 191 and 203:

    $user_diseases = array(
            'columns' => 4,
            'id' => 'osaki_user_diseases',
            'classes' => 'osaki-input osaki-select has-multiple',
            'label' => __('Diseases', 'almazen'),
            'last_column' => false,
            'required' => false,
            'options' => $user_diseases_options,
            'type' => 'select',
            'multiple' => true,
            'default' => '',
          );
          array_push($fields, $user_diseases);

    This is a code in PHP that render a multiple select using your lifterlms_get_person_fields filter. Please re-check the code.

    Theese lines creates something like this:

    <select class="llms-field-select osaki-input osaki-select has-multiple" id="osaki_user_diseases" name="osaki_user_diseases" style="display: none;" multiple="multiple"><option value="dont_specify">No quiero especificar mis enfermedades</option><option value="arthritis">Artritis</option><option value="chronic_patient_caregiver">Cuidador de paciente crónico</option><option value="aids">VIH/SIDA</option><option value="type_1_diabetes">Diabetes tipo 1</option><option value="type_2_diabetes">Diabetes tipo 2</option><option value="cancer_survivor">Superviviente de cáncer</option><option value="chron_disease">Enfermedad de Crohn</option><option value="ulcerous_colitis">Colitis Ulcerosa</option></select>

    The select works nice when selecting multiple options but when the date is sent via POST it saves only one option in database. I believe there is a problem with your management of POST data created by a multiple select. Instead of saving an array of values your proccess saves only one string value.

    Thanks in advance Natalie.

    Plugin Contributor Saurabh

    (@saurabhshukla)

    Hi @hamlet237,

    The default LifterLMS fields API doesn’t support multi select as of now. That multiple=true parameter will not do anything and you would end up with a single select only. See: https://github.com/gocodebox/lifterlms/blob/3.35.2/includes/llms.functions.core.php#L529-L681. Nowhere is a multiple select used in fields here http://github.com/gocodebox/lifterlms/blob/3.35.2/includes/class.llms.person.handler.php

    So,I’m not sure how you have a multiple select working with the code that you’ve shared.

    You’d have to go a step further and filter the form field markup to make this happen, as of now. However, if you could make changes to support the multiple parameter and send in a PR to our Github repo, we’d be more than happy to accept it!

    If the multiple select would work, there’s nothing in the code that would do what you’ve suggested. For example, the registration form straightaway dumps the post data without stripping anything anywhere: https://github.com/gocodebox/lifterlms/blob/09c3353aaeb2a8785868f2cf1cf67c4146e94068/includes/forms/controllers/class.llms.controller.registration.php#L73

    Could you please check and confirm everything again?

    Best

    hamlet237

    (@hamlet237)

    Hi @saurabhshukla .
    Yesterday I made a fork and two commits about the topic. Try the code and confirm that it works. For me it is working now.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.