• Resolved gella2002

    (@gella2002)


    Hello,
    thank you very much for your brilliant plugin!
    Could you please advise, how to customize pdb_single template, if I’d like to exclude some fields depending on a condition?
    I’d like a statement like “If a field “pay_services_approved” is false (unchecked) then exclude field “pay_services_text” but I’m absolutely nothing in php… would be very grateful for your help.

    Thank you very much!

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter gella2002

    (@gella2002)

    I tried this code

    <?php
    if ($this->record->admin->fields->'approved_pay'->'yes' {
    $exclude = array('viewlink','email','diploma');
    } else {
    $exclude = array('viewlink','email','diploma','pay_services');
    }
    ?>

    to no avail unfortunately. Website keeps on telling me about syntax error on the line starting with “if”. Could you please check it? Thanks in advance!

    Plugin Author xnau webdesign

    (@xnau)

    I’m really sorry, but I can’t provide basic programming instructions. Editing templates requires an understanding of how PHP works in a template. I would suggest looking for a tutorial on editing WordPress template, they are very similar to the plugin templates.

    Thread Starter gella2002

    (@gella2002)

    Hello Xnau, thanks for replying! I’ve spent several hours today and yesterday googling and reading wordpress tutorials on that topic. I’ve learned how to create custom templates and exclude fields using your plugin, this already works. I completely understand that you have no wish to give php lessons here.
    But concerning this particular issue seems like I need help of people who know more than I do. Would some donation for further plugin development probably make you feel more inclined to help me? Anyway I’m going to find someone to solve this for me for a price, it’d be more appropriate to deal with the plugin’s developer than with someone else.

    If you feel like you don’t want to do it anyway please mark this topic as resolved.

    Plugin Author xnau webdesign

    (@xnau)

    OK, what exactly do you want to do?

    Thread Starter gella2002

    (@gella2002)

    Thank you that you agreed! I’ve just donated a bit, please feel absolutely free to correct me concerning the amount if you find that your help would not fairly correspond with it, because I’ve had not so much experience in estimating these issues ??

    Well, what I need to do: I want participants to fill in a field describing their services (say, “pay_services” text-area field). If a participant donates to the website, this field becomes visible on his single page (template “pdb-single”).
    If the participant hasn’t donated, this field is not displayed. This is controlled by admin by checking a checkbox (“approved_pay”, group of fields “admin”, values “yes,no”)

    Also I need to have some fields excluded from template, I’ve already implemented this like $exclude = array('viewlink','email','diploma') in my custom template.

    So I need to add an if-then statement to custom template based on pdb-single template, according to my condition: if the field “approved_pay” is not checked, then the fields ‘pay_services’, ‘viewlink’,’email’,’diploma’ are excluded. If the field “approved_pay” is checked as true, then only ‘viewlink’,’email’,’diploma’ are excluded.

    Thank you once again!

    Plugin Author xnau webdesign

    (@xnau)

    OK, well you can access all the values of a record using:

    $this->participant_values['fieldname']

    so then, you use that to select your exclude array like you did before:

    <?php
    if ($this->participant_values['approved_pay'] === 'yes') {
    $exclude = array('viewlink','email','diploma');
    } else {
    $exclude = array('viewlink','email','diploma','pay_services');
    }
    ?>
    Thread Starter gella2002

    (@gella2002)

    Thank you Xnau, worked like charm!
    P.S. I’ve tried the same code yesterday, taken from here, but it didn’t work either. Now I see that there need to be three “===” instead of two ?? good to know it )
    Have a nice day!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Customizing single template’ is closed to new replies.