WordPress.org

Ready to get started?Download WordPress

Forums

Participants Database
Filter on a per-page basis? (9 posts)

  1. blerb795
    Member
    Posted 2 years ago #

    I'll explain my setup briefly so my question makes sense:
    I have a website for a volunteer organization that has separate posts for each volunteering event. I've already inserted a PDB signup form on each event page, and I used the hidden field feature to log which post/page the signup came from.

    I understand that the [pdb_list] shortcode can be filtered to only show signups if they match a certain criteria, but can that criteria be "dynamic" based on where the list is placed? As in, can each event page show a list of who has signed up for that event and that event only?
    Thank you for your help, and please do not hesitate to ask if you need further clarification.

    http://wordpress.org/extend/plugins/participants-database/

  2. xnau
    Member
    Plugin Author

    Posted 2 years ago #

    blerb795,

    Check out "hidden fields" these can be set up to dynamically assign a property from the $post or $wp_user objects. Then in your [pdb_list] shorcode filter for the value you stored in the hidden field.

    specifically:
    1. create a new field name "post name" and make it a hidden field with a default value of 'post->post_name'...add it to the signup form. when someone signs up, the post slug of the page the shortcode was on will be recorded.

    2. in your [pdb_list] shortcode, add a filter like this: [pdb_list filter="post_name=slug"] Now only people who signed up on that post will be listed. Note the name of the field is used, not the title.

    anyway, check the docs about hidden fields. http://wordpress.org/extend/plugins/participants-database/other_notes/

  3. blerb795
    Member
    Posted 2 years ago #

    I get how to use the hidden fields--I already have a field for the page that the form was submitted from.
    I'm trying to make it so that [pdb_list] can be set up something like [pdb_list filter='my_field_name=$post'] so that each page has a list of people who signed up from that page itself (each page would have a signup and a list of people who signed up)

    I guess shortcodes can't contain php though, so that currently does not work.
    Any ideas?

  4. xnau
    Member
    Plugin Author

    Posted 2 years ago #

    Ah, I see. The way to do this is to put the shorcode in the template using the do_shortcode function. You can use a php variable in the argument string:

    <?php echo do_shortcode('[pdb_list filter="my_field_name='.$post->post_name.'"]') ?>

  5. blerb795
    Member
    Posted 2 years ago #

    Didn't work for me--I got no records found every time.
    I ended up using a rather inefficient method:

    $longname = single_post_title("", FALSE);
    $eventname = substr("$longname", 0, 11);

    and then I used filter="event_name~'.$eventname.'"
    It seems like for some reason the filter was being too strict and it wouldn't work with your method, so I had to take the first 11 characters of the post name and filter with that.

    If you can think of a more elegant way to do this, please let me know!

    Another thing: is it possible to change the text of "No records could be found?"

  6. xnau
    Member
    Plugin Author

    Posted 2 years ago #

    blerb795,

    Why don't you try using the post ID?

    Also, if there's a problem suing the post_name, perhaps you could tell me what your post_name for the page was so I can see if there's a bug.

  7. blerb795
    Member
    Posted 2 years ago #

    I haven't been using post ID because I want the csv to still have the "friendly" name of the event that people are attending.
    (Which is why my hidden field logs $post->post_title, rather than post_name)
    But even when I used the filter with the variable, I got no records found.

    I checked the value of the variable by putting an echo $post->post_title and I manually made sure there was a participant with the exact same characters in the field of the record.

    Is the event name too long, perhaps? It is "Turtleback Book Fair Set-up"
    Or maybe the hyphen is messing it up?

    Thank you for all your help..it's rare to get so much help nowadays :)

  8. xnau
    Member
    Plugin Author

    Posted 2 years ago #

    blerb795,

    I understand about using the post_title so people will get a readable data field, but you could also capture the post ID or name...they will be a whole lot more reliable when it comes to filtering the list.

    It's the spaces, not the hyphen messing things up in your example. The shortcode filter currently doesn't deal well with spaces.

    As to helping people using the plugin, well, it's how I learn to make it better.

  9. blerb795
    Member
    Posted 2 years ago #

    Ah, so you're suggesting I also capture the post ID and filter by that, and capture the post_title just for display/logging purposes?
    That makes a lot of sense..I'll go try it out now.
    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic