Showing a Record Edit Form Based on a Value in the Record
-
I have successfully set up multiple sign-up forms for three different types of people, and now want to set up the record edit page so that each type can edit the appropriate fields. This page (https://xnau.com/showing-a-record-edit-form-based-on-a-value-in-the-record/) deals with exactly this, but I can’t get it to work.
I have saved the code for pdb-record-usertype.php and customized it for my fields and groups as follows:
/* * first, check for the value that determines what kind of * record edit form to show */ $type = $this->participant_record['source_page']; /* * now, show the record edit form for that type */ echo 'Source page: ' . $type; switch ( $type ) { case 'sign-our-letter-laity': echo do_shortcode('[pdb_record groups="main,church_of_england,laity"]'); break; case 'sign-our-letter-clergy': echo do_shortcode('[pdb_record groups="main,church_of_england,clergy"]'); break; case 'sign-our-letter-anglican-communion': echo do_shortcode('[pdb_record groups="main,anglican_communion"]'); break; }
I added the line
echo 'Source page: ' . $type;
for debugging purposes.I uploaded pdb-record-usertype.php to my theme’s templates folder, and put the shortcode
[pdb_record template=usertype]
in my record edit page, after some introductory text.Initially the record edit page output the php code literally, so I added the
<?php
tag at the top of the file – wondering why it wasn’t there in the code as given.But now something goes wrong with the page: it displays up to the page heading and the introductory text, and then shows ‘Source page:’ and nothing else. Clearly
$type
must be empty. I’ve double-checked that ‘source_page’ is the correct field name.Debug.log contains the following warning, which looks as if it could be significant:
PHP Warning: session_start(): Cannot start session when headers already sent in /var/www/clients/client54/web203/dev/wp-content/plugins/participants-database/vendor/wp-session-manager/wp-session-manager.php on line 46
I’d be grateful for any help to get this working!
My system is as follows:
Ubuntu 18.04 VPS running ISPConfig, fully updated
Apache 2.4.29
MySQL 15.1 (10.1.38-MariaDB)
PHP 7.2
WordPress 5.1.1
Participants Database 1.9.3.2The page I need help with: [log in to see the link]
- The topic ‘Showing a Record Edit Form Based on a Value in the Record’ is closed to new replies.