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!
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.
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.
OK, what exactly do you want to do?
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!
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');
}
?>
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!