• Resolved Mario Z.

    (@maze233)


    Hi Roland,

    First, thanks for this amazing plugin!
    I did some small customizations to get what I want with this plugin for a new website and now I have one question to the dropdown form element.

    Is it possible to get the dropdown values from the entries of another field? For example if I have a field called “event_title” and now want to dynamically display all the available event titles in this dropdown.

    I had a look a the documentation but couldn’t find something that helped me.
    Hope you understand what I mean.

    Thanks!
    Mario

    https://www.ads-software.com/plugins/participants-database/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author xnau webdesign

    (@xnau)

    The plugin doesn’t have this capability, you have to use a custom template to assemble your dropdown options for your custom search.

    Thread Starter Mario Z.

    (@maze233)

    Thanks!

    I tried to get it work but my PHP knowledge is very limited. Maybe you can point me into the right direction.

    In a specific signup form I want to display a dropdown with the values from another field (in another group) which is not enabled in the settings for the signup form.
    How can I get this values into the $this object for example?

    Plugin Author xnau webdesign

    (@xnau)

    Usually, with questions like this, I ask what it is you want to do. It’s possible that what you think is the solution to your problem won’t work. I say this because it doesn’t make sense to me to use the values of one field to search in another…but that may be because I don’t know what you’re trying to accomplish.

    So–what is it you want your search interface to do? There may be an easier solution.

    Thread Starter Mario Z.

    (@maze233)

    Okey so this is what I want to do:

    I have one signup form on which people can offer help for an activity. For example “Learn how to draw”. This title will be saved as the “activity_title” in the database.
    After that there is another page on which all those offers are displayed by the [pdb_list] shortcode and people can sign up for this offers. For that I added a signup button to a custom pdb_list template which redirects the people who want to participate to another signup form.

    And now in this signup form for participants they have to enter last name, first name, etc. and need to choose for which activity they want to signup. To select an activity I want to show a dropdown field which contains all saved records from the field “activity_title” as the dropdown values.

    Hope this explains my thoughts.

    Plugin Author xnau webdesign

    (@xnau)

    Sure, OK. You don’t explain if the people who offer the help will type in the name of their activity, or if they choose it from a list. If you let them type it in, you may end up with several slightly different activities that are actually the same activity…this could be confusing to your second group of users. I mention this so you can think about how that might work.

    The solution is the same either way.

    You can use code something like this to produce your dropdown:

    <?php
    global $wpdb;
    $field = 'activity_title';
    $activities = array();
    // grab the unique stored values from the field
    $result = $wpdb->get_results('SELECT DISTINCT p.' . $field . ' from ' . Participants_Db::$participants_table . ' p WHERE p.' . $field . ' <> ""', ARRAY_N);
    // now we convert the query result into a simple array
    foreach($result as $value) {
      $activities[] = current($value);
    }
    // print the dropdown
    echo PDb_FormElement::get_element(array(
        'name' => 'selected_activity',
        'type' => 'dropdown',
        'options' => $activities
            )
        );
    ?>

    The database query gets all unique values stored in the ‘activity_title’ field, then makes a dropdown selector with the values.

    Thread Starter Mario Z.

    (@maze233)

    Perfect! Exactly what I wanted to achieve!

    Yeah thats right. The people type in the name of their activity so this could happen. I think we will prevent this with an approval process.
    Speaking of an approval process, I can filter the results easily with the “filter” statement in the pdb_list shortcode but as far as I know the pdb_signup shortcode doesen’t support that anyway.

    Is it possible to filter this dropdown with php code so that only approved activities/activity titles are displayed?
    For that I already have a field named “approved” with the values “yes” and “no”.

    Plugin Author xnau webdesign

    (@xnau)

    OK, well if you want to only include approved activities, you need to add that to the query, like this:

    'SELECT DISTINCT p.' . $field . ' from ' . Participants_Db::$participants_table . ' p WHERE p.' . $field . ' <> "" AND p.approved = "yes"'

    Or something like that…you get the idea.

    Thread Starter Mario Z.

    (@maze233)

    Perfect, thanks very much!

    I really appreciate your help!

    rbarron

    (@rbarron)

    Was going to ask the exact same question – VERY timely answer, thank you.

    I’d like to be able to add donations to the DB for donors that already exist. Seems like I now have a path to achieve this, you’re the BEST.

    ….. Rick

    kiddosorna

    (@kiddosorna)

    $posts = $wpdb->get_results(“SELECT services,amount FROM inside_mandir”);

    <p>Services<span class=”red”>*</span>
    <span class=”wpcf7-form-control-wrap menu-903″><select name=”category” class=”wpcf7-form-control wpcf7-select wpcf7-validates-as-required” aria-required=”true” aria-invalid=”false”>
    <option value=”<?php echo $posts ;?>”><?php echo $posts ;?></option>
    ?></select></span></p>

    it returns $array in select drop-down.i need services-amount value in dropdown EG:(AAA-$11)

    how i get this value

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Dropdown values from specific field’ is closed to new replies.