Disable [pdb_record] if approved ?
-
Hello,
Is it possible to disable [pdb_record] (Editing Entries) for some people (if i check “approved” for example) ?
-
Well, there isn’t anything like this built in to the plugin, but you could create a custom template for the “pdb_record” shortcode that only shows the form if the value of a approval field is correct. Definitely need to PHP skills to make that work.
OK. Do you think you could do an update with this option ?
That’s because i use your great plugin for sport event and i don’t want that my particpants may change their informations as soon as i have received their paymentThis is a custom functionality for your site. You may need to enlist some technical help if it isn’t something you can do yourself.
Thank you for your answer. Where can i get php help ? here ?? ?
OK, I can give the the basic idea to use. You’ll need to start with a custom template, using the “pdb-record-default.php” template. Copy that into your theme directory into a folder named “templates”
In the file, you just need to test for the value and the use that to display the form or display whatever you want to show if their record has not been approved yet. All of the record values are in an array, so using the name of the field you want to test, you’d do something like this:
<?php if ($this->participants_values['approved'] === 'yes' ) : ?> (show your form here) <?php else ?> (record not approved) <?php endif ?>
You just need to adapt that to how you want it to work in your case.
ok for the first part. So in my new record page, i put this shortcode [pdb_record template=”river”].
pdb-record-river.phpBut i really don’t know how to put your code and adapt it with this code in my file pdb-record-river.php
<?php /* * default template for the [pdb_record] shortcode for editing a record on the frontend * * this template uses a table to format the form */ ?> <div class="wrap <?php echo $this->wrap_class ?>"> <?php // output any validation errors $this->print_errors(); ?> <?php // print the form header $this->print_form_head() ?> <?php while ($this->have_groups()) : $this->the_group(); ?> <?php $this->group->print_title() ?> <?php $this->group->print_description() ?> <table class="form-table"> <tbody class="field-group field-group-<?php echo $this->group->name ?>"> <?php // step through the fields in the current group while ($this->have_fields()) : $this->the_field(); ?> <tr class="<?php $this->field->print_element_class() ?>"> <th><?php $this->field->print_label() ?></th> <td id="<?php $this->field->print_element_id() ?>"> <?php $this->field->print_element(); ?> <?php if ($this->field->has_help_text()) : ?> <span class="helptext"><?php $this->field->print_help_text() ?></span> <?php endif ?> </td> </tr> <?php endwhile; // field loop ?> </tbody> </table> <?php endwhile; // group loop ?> <table class="form-table"> <tbody class="field-group field-group-submit"> <tr> <th><h3><?php $this->print_save_changes_label() ?></h3></th> <td class="submit-buttons"> <?php $this->print_submit_button('button-primary'); // you can specify a class for the button ?> </td> </tr> </tbody> </table><!-- end group --> <?php $this->print_form_close() ?> </div>
I tried a little but it doesn’t work..
If the record is approved and the field is checcked, i just want for example to delete submit button in this page. How to do that ?
That is not hard, but it could be confusing to your users: they may think something is wrong. It’s better to explain to them why they can’t fill out the form.
Yes ok. But i put your code and it doesn’t work
<?php /* * default template for the [pdb_record] shortcode for editing a record on the frontend * * this template uses a table to format the form */ ?> <?php if ($this->participants_values['approved'] === 'non' ) : ?> <div class="wrap <?php echo $this->wrap_class ?>"> <?php // output any validation errors $this->print_errors(); ?> <?php // print the form header $this->print_form_head() ?> <?php while ($this->have_groups()) : $this->the_group(); ?> <?php $this->group->print_title() ?> <?php $this->group->print_description() ?> <table class="form-table"> <tbody class="field-group field-group-<?php echo $this->group->name ?>"> <?php // step through the fields in the current group while ($this->have_fields()) : $this->the_field(); ?> <tr class="<?php $this->field->print_element_class() ?>"> <th><?php $this->field->print_label() ?></th> <td id="<?php $this->field->print_element_id() ?>"> <?php $this->field->print_element(); ?> <?php if ($this->field->has_help_text()) : ?> <span class="helptext"><?php $this->field->print_help_text() ?></span> <?php endif ?> </td> </tr> <?php endwhile; // field loop ?> </tbody> </table> <?php endwhile; // group loop ?> <table class="form-table"> <tbody class="field-group field-group-submit"> <tr> <th><h3><?php $this->print_save_changes_label() ?></h3></th> <td class="submit-buttons"> <?php $this->print_submit_button('button-primary'); // you can specify a class for the button ?> </td> </tr> </tbody> </table><!-- end group --> <?php $this->print_form_close() ?> </div> <?php else ?> Sorry you can't edit anymore / vous ne pouvez plus éditer votre fiche <?php endif ?>
What is wrong ?
Thank you.Probably, you have to test the opposite:
<?php if ($this->participants_values['approved'] !== 'oui' ) : ?>
I don’t why but it doesn’t work with this code
https://img4.hostingpics.net/pics/896536par.jpg
<?php /* * default template for the [pdb_record] shortcode for editing a record on the frontend * * this template uses a table to format the form */ ?> <?php if ($this->participants_values['approved'] === 'oui' ) : ?> Sorry you can't edit anymore / vous ne pouvez plus éditer votre fiche <?php else ?> <div class="wrap <?php echo $this->wrap_class ?>"> <?php // output any validation errors $this->print_errors(); ?> <?php // print the form header $this->print_form_head() ?> <?php while ($this->have_groups()) : $this->the_group(); ?> <?php $this->group->print_title() ?> <?php $this->group->print_description() ?> <table class="form-table"> <tbody class="field-group field-group-<?php echo $this->group->name ?>"> <?php // step through the fields in the current group while ($this->have_fields()) : $this->the_field(); ?> <tr class="<?php $this->field->print_element_class() ?>"> <th><?php $this->field->print_label() ?></th> <td id="<?php $this->field->print_element_id() ?>"> <?php $this->field->print_element(); ?> <?php if ($this->field->has_help_text()) : ?> <span class="helptext"><?php $this->field->print_help_text() ?></span> <?php endif ?> </td> </tr> <?php endwhile; // field loop ?> </tbody> </table> <?php endwhile; // group loop ?> <table class="form-table"> <tbody class="field-group field-group-submit"> <tr> <th><h3><?php $this->print_save_changes_label() ?></h3></th> <td class="submit-buttons"> <?php $this->print_submit_button('button-primary'); // you can specify a class for the button ?> </td> </tr> </tbody> </table><!-- end group --> <?php $this->print_form_close() ?> </div> <?php endif ?>
nothing appear except the menu.
It’s all in the details. You should set up your error log so you can see where the problems are, that will be very helpful.
Also, if something doesn’t work, and you want someone to help, you need to be specific about how it doesn’t work. I see an error, but I have no idea if that is the problem.
<?php else ?>
has to be<?php else : ?>
Thank You for your answer.
I changed <?php else ?> to <?php else : ?> and my page is ok now. thanks !
But participants can still change their informations though i check the field approved to “oui” or “non”. Nothing change.So i get no error on page but nothing change. Is there an error with that code :
<?php if ($this->participants_values['approved'] === 'oui' ) : ?>
<?php endif ?> change also to <?php endif; ?> exact or not ?
but nothing changeMust be a colon, not semicolon.
So it doesn’t work with :
<?php /* * default template for the [pdb_record] shortcode for editing a record on the frontend * * this template uses a table to format the form */ ?> <?php if ($this->participants_values['approved'] === 'oui' ) : ?> Sorry you can't edit anymore / vous ne pouvez plus éditer votre fiche <?php else : ?> <div class="wrap <?php echo $this->wrap_class ?>"> <?php // output any validation errors $this->print_errors(); ?> <?php // print the form header $this->print_form_head() ?> <?php while ($this->have_groups()) : $this->the_group(); ?> <?php $this->group->print_title() ?> <?php $this->group->print_description() ?> <table class="form-table"> <tbody class="field-group field-group-<?php echo $this->group->name ?>"> <?php // step through the fields in the current group while ($this->have_fields()) : $this->the_field(); ?> <tr class="<?php $this->field->print_element_class() ?>"> <th><?php $this->field->print_label() ?></th> <td id="<?php $this->field->print_element_id() ?>"> <?php $this->field->print_element(); ?> <?php if ($this->field->has_help_text()) : ?> <span class="helptext"><?php $this->field->print_help_text() ?></span> <?php endif ?> </td> </tr> <?php endwhile; // field loop ?> </tbody> </table> <?php endwhile; // group loop ?> <table class="form-table"> <tbody class="field-group field-group-submit"> <tr> <th><h3><?php $this->print_save_changes_label() ?></h3></th> <td class="submit-buttons"> <?php $this->print_submit_button('button-primary'); // you can specify a class for the button ?> </td> </tr> </tbody> </table><!-- end group --> <?php $this->print_form_close() ?> </div> <?php endif ?>
No error on page though…
- The topic ‘Disable [pdb_record] if approved ?’ is closed to new replies.