The way to do this is to create a custom template for your list (explained here) and then add your link to the participant record page. First, you need to create a field that will provide something to click on…let’s say it’s a read-only text field named ‘edit’ In your list template, add this after the line that has “$this->the_field()”
<?php if ($this->field->name == 'edit' ) {
$participant_data = Participants_Db::get_participant($this->record->record_id);
$record_edit_link = Participants_Db::add_uri_conjunction(get_permalink(Participants_Db::$plugin_settings['registration_page'])) . "pid=" . $participant_data['private_id'];
$this->field->value = '<a href="' . $record_edit_link . '">edit</a>';
} ?>
I must be missing something. After executing the steps below, I get (for example) the following displaying on my [pdb_list] page, instead of the defaulted word, “VIEW”:
edit
Clicking on the link takes me to that record, but in a view-only mode. What am I missing?
My steps:
– created a read-only field called EDIT with VIEW as its default. Made it sortable.
– Copied pdb-list-detailed.php to my local machine. Edited it to include your insert below the “$this->the_field()” line. Saved the file.
– Uploaded pdb-list-detailed.php to a directory under my plugin. I’m using “responsive” as my theme, and my directory under wordpress’s themes directory is responsive/themes/pdb-list-detailed.php.
Make sure you have the “Participant Record Page” setting pointing to the page with the [pdb_record] shortcode.
The template has to go in a directory named “templates”
Probably something like: wp-content/themes/responsive/templates/pdb-list-detailed.php
The word “edit” is hard-coded into the code I gave you…you can replace that with the $this->field->value if you want it to pick up the default value of the field.
OK. No luck. So I did the following: (1) I did a fresh install of wordpress and your plugin, leaving fields unchanged. (2) created a read-only database field named “edit” and made it sortable. Also defaulted its value to “EDIT”. (3) Created a target page for the pdb_list shortcode. Created a new template based on “pdb-list-detailed.php” called “pdb-list-ajpeditable.php”. They are identical, except that the latter has your code snippet inserted. (4) Uploaded my new template to a subdirectory of my responsive theme called “templates”. (5) Completed configurations and double-checked checked my settings for pdb_record shortcode page. (6) Put the following shortcode on my “pdb_list” page: “[pdb_list template=”ajpeditable”].
Still no luck! What I get is a column in my records listing that has a column heading called EDIT, but rather than a hyperlink for each record leading to an editable complete record, I get the following string:(this is the one for my 1st of 3 test records):
edit
I wish I could debug this myself, but can we fix my blindspot?
The key is this: “The word “edit” is hard-coded into the code I gave you…you can replace that with the $this->field->value if you want it to pick up the default value of the field.”
Here it is with the change I suggested you try:
<?php if ($this->field->name == 'edit' ) {
$participant_data = Participants_Db::get_participant($this->record->record_id);
$record_edit_link = Participants_Db::add_uri_conjunction(get_permalink(Participants_Db::$plugin_settings['registration_page'])) . "pid=" . $participant_data['private_id'];
$this->field->value = '<a href="' . $record_edit_link . '"><?php echo $this->field->value ?></a>';
} ?>