Hube2 / contact-form-7-dynamic-select-extension

Dynamic Select Field for Contact Form 7
18 stars 8 forks source link

Examples don't work #9

Open aManNamedJed opened 6 years ago

aManNamedJed commented 6 years ago

The plugin may or may not even work. The documentation you have provided is all over the place, and none of your screenshots even match your code examples. Can you please update your documentation to be consistent across the board? It's not clear how to get this working. I am debugging the code and still have no idea.

aManNamedJed commented 6 years ago

Just to help out, so I'm not just an angry troll:

Register my filter to get the events and pass them down

add_filter('cf7_custom_get_events', function($choices, $args = []){

    $events = get_posts("post_type=event&posts_per_page=-1");

    echo "<pre>";
    var_dump($events);
    die;
    echo "</pre>";

    $choices = array(
        '-- Make a Selection --' => '',
        'Choice 1' => 'Choice 1',
        'Choice 2' => 'Choice 2',
        'Choice 3' => 'Choice 3',
        'Choice 4' => 'Choice 4',
        'Choice 5' => 'Choice 5'
    );
    return $choices;
}, 10, 2);

Then within the CF7 Form, give it that filter I passed in as the first parameter

[dynamicselect event "cf7_custom_get_events"]
[submit "Send"]
Hube2 commented 6 years ago

Yes, the documentation on how to use is a bit lacking. I will gladly accept put request if anyone wants to help contribute.

aManNamedJed commented 6 years ago

I created a PR for you. I hope this helps:

https://github.com/Hube2/contact-form-7-dynamic-select-extension/pull/10