Support » Plugin: Participants Database » Checkbox results as links

  • Resolved Sdarter


    This is coming together well for me, and I appreciate your responsiveness in the support forums!

    My database is of people who have completed certain courses, so one of the fields will be a checkbox field where we will select which courses the participant completed. So I have a list of Course A, Course B, Course C, etc., in the values field.

    What I would like is to be able to make those choices link to course descriptions. So in the output, if the participant completed Course A and Course C, they will list as links to a separate page.

    Can this be done? It seems simple in theory, but I’m not great at PHP. Trying to get better though!

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


    Yes, it’s possible, but a little tricky as the most direct way to do it is with string matching and replacing.

    The thing I’m not clear on is which shortcode are you using where you want the course names to be clickable? The single record?

    Anyway, the idea is you take the value (which is actually a series of values) break it up into it’s parts, and then give each part its link. Tell me which shortcode it’s for and I’ll go into more detail.

    The fields will show in the single record AND in the list. It is the “courses completed” field here:

    Workshop Graduates

    and if you click through you’ll see it on the single page as well.

    Plugin Author xnau webdesign


    Here’s an example I created for my test site. This goes after the line that has $this->the_field() in it:

    <?php if ($this->field->name == 'interests') {
    	foreach ($this->field->value as &$string){
    		switch ($string) {
    			case 'fishing':
    				$link = 'fishing-page';
    			case 'rock climbing':
    				$link = 'rock-climbing-page';
    				$link = false;
    		if ($link) $string = sprintf('<a href="%s">%s</a>',$link,$string);
    } ?>

    You just need to replace the string I used for my test case with the strings you’ll have in your courses field. My field was named “interests” so you’ll have to change that to the name of your courses checkbox field. This code will work in both templates.

    Note that this will only work for multi-select fields (like multiselect checkbox) that can have multiple values because such fields are stored as arrays.

    AWESOME! Thank you so very very much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Checkbox results as links’ is closed to new replies.