Posted on by

Adding an Edit Record Link to the Frontend List

Let’s say you want some users who do not have access to the admin section to be able to edit records. You want to show them a list of records that includes a link to a record edit page.

Set Up the Participant Record Page

First make sure your record edit page (known as the Participant Record Page) is properly set up. This is a page which has the [pdb_record] shortcode in it and will therefore show the user’s editable record when properly accessed. Make sure it’s configured in the plugin settings under the Record Form tab: the “Participant Record Page” setting needs to point to your record edit page.

Setting up the Link

You’ll be showing a list of records with a link to edit a record in each listing, so you’ll need to decide what field the link should go on. For this tutorial, we create a new “placeholder” field (on the Manage Database Fields page) and name it “Edit Link” and give it a default value of “Edit.” (The default value can actually be any text you want shown as the clickable text) This column won’t do anything other than provide clickable text. Go to the Manage List Columns Page to add your edit link to the list display.

It’s important that the field you choose for your edit link is not the same field as you have defined as the “Single Record Link Field” in the settings.

The Custom Template

In this article, I am providing an example template that you can use. It is very important that you place that template file in the correct location on your website. Please read Using Participants Database Custom Templates for the details.

The custom template example I provide is named pdb-list-edit-link.php To use the template, add the name of the template to the list shortcode like this: [pdb_list template=edit-link]

How the Code Works

Here is the main loop that generates the list as seen in “pdb-list-default.php”:

<tbody>
<?php while ( $this->have_records() ) : $this->the_record(); // each record is one row ?>
  <tr>
    <?php while( $this->have_fields() ) : $this->the_field(); // each field is one cell ?>
      <td class="<?php echo $this->field->name ?>-field">
        <?php $this->field->print_value() ?>
      </td>
  <?php endwhile; // each field ?>
  </tr>
<?php endwhile; // each record ?>
</tbody>

We need to alter the value of a field before it’s displayed, so that goes inside the second loop, before anything is printed.  The plugin has a convenient way to do that: a template helper class with methods that give us easy ways to work with the field values. We set that up by instantiating the Template class object using the current record object ($this).

Here is the code for a template that shows an edit link for each record in the list. This replaces the code shown above.

<tbody>
<?php while ( $this->have_records() ) : $this->the_record(); // each record is one row ?>
    <?php $record = new PDb_Template($this); ?>
  <tr>
    <?php while( $this->have_fields() ) : $this->the_field(); // each field is one cell ?>
      <td class="<?php echo $this->field->name ?>-field">
        <?php 
        /*
         * put the edit link URL into the link property of the field
         */
        if ($this->field->name == 'edit_link') {
          $this->field->link = $record->get_edit_link();
        }
        $this->field->print_value();
        ?>
      </td>
  <?php endwhile; // each field ?>
  </tr>
<?php endwhile; // each record ?>
</tbody>

The way this works, is for each new record, the Template class is instantiated with that record’s data. Then we start looping through the fields in that record. When the “edit_link” field is getting shown, we make the field clickable by putting the edit link URL into the field’s “link” property. The $record->get_edit_link() method is provided by the template object, and makes getting the correct URL of your record edit page easy.

You can use this technique to add a link to any text or image field in the list. To make a field value clickable, set the “link” property of the field ($this->field) to the URL you want the click to go to. If the field already has a link on it, the new link will replace it.

The get_edit_link() property uses the global setting “Participant Record Page” to determine which page the editable record is shown on. You can also set that in the function itself if for some reason you wanted it to be different for this particular template: $record->get_edit_link('record-edit') if you want to send them to a page with the slug “record-edit.”

The Complete Template

Here is the whole template for you to use if you don’t want to create your own. The link to download it is at the bottom of the code window.

198 thoughts on “Adding an Edit Record Link to the Frontend List

  1. Hi Roland,

    I have created a log list using a custom template based on pdb-log_list-default and placed the get edit link code into the relevant section. Although it is creating a link, it is not pulling the UPID number into the link so returns a page with no record found.

    Is it possible to pull an edit link through the log list?

    1. I’ve turned debugging on and receiving the following error…


      Warning: array_key_exists() expects parameter 2 to be array, null given in /home3/xqxiavmy/public_html/FIPFAclassification/wp-content/plugins/participants-database/classes/PDb_Template.php on line 608

    2. Hi Alex,

      The PDb_Template class can’t be used in a Global Log List template currently, I have it on my to do list, but it’s not implemented yet.

      I have posted an example template that shows how to set the record edit link in a Global Log List with the current version of the Participant Log plugin.

      https://gist.github.com/xnau/9579c48af664cccbf150a92d40655b18

      1. Thank you Roland,

        I’m getting some weird results with the code. From what I can work out it is using the number of log record id to reference the participant private id in participant table. E.g if the log record_id is 6 but is attached to participant id 2, the log_edit_link links to participant id 6 not 2.

        I’m guessing it’s just a case of changing a reference in the function, but I’m still learning so not sure what or where.

        1. A bit of reading and I think I’ve fixed it.
          Line 17 should be
          $record_id = $wpdb->get_var( 'SELECT `record_id` FROM ' . \pdblog\Plugin::log_table_name( $log_list->shortcode_atts['log_name'] ) . ' WHERE `record_id` = "' . $entry_id . '" LIMIT 1' );

          Many thanks again

        2. The code is correct, the “record_id” column of the log entry is the id of the Participants Database record the log entry is attached to. We are using that value to build the record edit URL.

  2. Good day sir,

    How would one go about using this within – pdb-single-default.php for a single link? Or am I missing a simpler way within settings to edit a single record.

    Also, after editing a record and saving, is there a way to have it go back to the [pdb_single]?

    Thank-you,
    Daz

    1. To add an edit link to the single record display, you need to use a custom template. The way to get and apply the link is very similar to the way you do that for a list template. You could also add the link as a separate item (rather than apply it to a PDB field as it is done in the list template).

      To set up a return to the single record after the user edits the record, you will need to use a custom template for the pdb_record shortcode also. You can use the PDb_Template class to get the link back to the single record page, then set the “submission_page” property to that link…you can do that with something like this in the header of the record shortcode custom template:

      $record = new PDb_Template( $this );
      $this->submission_page = $record->get_detail_link();

      1. Thanks for the reply Roland,
        I’m close, I think my problem is where I would place the code on my template. I’m using single_default as the starting point but it wants to repeat the value of the last field.

        Daz

      2. How about changing the redirect page if adding a participant from within admin?

        1. Is it possible to have it redirect to the pdb_single page with the data submitted for the new participant?

        2. You can use the “action” attribute of the [pdb_record] shortcode to send the user to another page after submitting an update.

        3. This is not possible.

        4. Thank-you, I can stop trying and start looking for a work around.
          Appreciate your help, you rock!

      3. Hi Roland:
        How to close the editable-[pdb_record] once the save button is clicked ?
        Just like when the submit button is clicked from the sign-up form..
        Thanks
        rdgs
        javz

        1. You can use the “action” attribute to send them to a different page when they submit the form. Put the [pdb_update_thanks] shortcode on that page to shopw the feedback message.

          [pdb_record action="update-thanks"]

        2. Hi Roland:
          I created a page (Success) w/ shortcode = [pdb_update_thanks] and
          then on the (Record Page), I used the shortcode = [pdb_record action="update-thanks"], but when I clicked the Save Button, it displayed the message “Your information has been updated” (w/c is the default record updated message from the record form settings) and the editable page is still on display… the action=”update-thanks” failed. I also tried to use with [pdb_user_record action=”update-thanks”, but same result, perhaps I missed to set something???

          Help pls. Thanks

        3. The value of the “action” attribute must be the name of the page with the [pdb_update_thanks] sortcode.

          The [pdb_user_record] shortcode does not support the use of the “action” attribute unless you edit the tutorial plugin to use it.

        4. Hi Roland:
          Still on the issue of “action”
          I used [pdb_record action="url slug"] , it worked, its been directed to that page, BUT, unfortunately, if I checked the DELETE checkbox in that editable-page and click the save button, the message “Record has been deleted” was not displayed anymore, only a blank page, How can I display a delete message???
          And this action=”url slug” does work with [pdb_user_record] WHY ?

          Thanks and need help.
          rdgs;javz

        5. It won’t show the deleted message, it’s not set up to do that, I’m sorry. You get a blank page because the record has been deleted, you will need to add some custom code to show a deleted message on that page.

        6. Hi Roland:
          You Said: ” you will need to add some custom code to show a deleted message on that page. ”
          1. HOW and WHERE to add ? Perhaps pdb_record_delete_switch ?
          2. Any similar sample(s) for reference or template?
          Thanks and still need advice.
          Rdgs; Javz

        7. You are using custom code to delete the record. A good way to do this is to add to that code a filter that changes the “thanks” message. The filter for that is pdb-update_thanks_message so you could use something like this:

          <?php add_filter( ‘pdb-update_thanks_message’, function( $message ) { 
             $message = "Your record was deleted.";
             return $message;
           } );  ?>

          For your reference, you can find the filter in the plugin code at around line 390 of classes/PDb_Signup.php

        8. Hi Roland:
          You mean to say that I will Insert this code:

          in pdb-record-delete-switch.php ?

          If YES, which line no. ? Perhaps below line 73 ? where I found the message code :

          if ( $success ) {
          Participants_Db::$plugin_options[‘no_record_error_message’] = __( ‘The record has been deleted.’ );

          Is my understanding correct?

          Thanks, need more advice.
          Rdgs;
          javz

        9. That code should replace the code that sets the “no record error mssage” since you’re providing a different way to show the same message.

        10. Hi Roland:
          I tried to follow your instruction, and came up with this:

          Participants_Db::$plugin_options [add_filter( ā€˜pdb-update_thanks_messageā€™, function( $message ) {
          $message = “Your record was deleted.”;
          return $message;
          } )];

          I did not get any errors with wp, but still it does not display any message when a record has been deleted.

          Is my coding Correct?

          Thanks, and need further advice.
          Rdgs;
          javz

        11. Take a look at the record delete plugin, I updated it with the filter for the thanks page message.

          https://gist.github.com/xnau/40ff2abd35fb856e3d06dbb4bdbc7169

        12. Hi Roland:
          I tried the your new code: pdb-record-delete-switch.php
          1. Installed/activate the plugin and tested it with the existing:
          update-thanks (page) w/ shortcode = [pdb_update_thanks]
          GIPs Record (page) w/ shortcode = [pdb_record action="update-thanks"]

          With update: It displays the message ” [pdb_update_thanks] ”
          With delete: It displays the message ” [pdb_update_thanks] ”

          I checked your new code and notice : add_filter( ‘pdb-update_thanks_message’, function( $message )
          So I changed the page into:
          update-thanks-message (page) w/ shortcode = [pdb_update_thanks_message]
          GIPs Record (page) w/ shortcode = “[pdb_record action="update-thanks-message"]
          But still result….
          So I removed the shortcode from the update_thanks_message (Page)
          It displayed a blank page both on the update and delete pages.

          Did I miss to set something?
          Thanks and need more advice..
          Rdgs;
          javz

        13. Hi Roland:
          I tried the your new code: pdb-record-delete-switch.php
          Installed/activate the plugin and tested it with the existing:
          update-thanks (page) w/ shortcode = [pdb_update_thanks]
          GIP Record (page) w/ shortcode = [pdb_record action="update-thanks"]

          But it displayed the short code instead of the message in both the update and delete pages.

          Did I miss something?
          Thank you and need more advice.

          Rdgs;
          javz

        14. If it shows the shortcode you have one of two issues: either the plugin is not activated or there is a syntax issue with the shortcode string itself. Use a shortcode block and make sure the syntax is correct.

        15. Hi Roland:

          I checked the plugin, its working and activated.
          I check the short code block and syntax, its correct.
          But, still same result, “Blank Message” both for update and delete.

          Remedy:
          I just created a page with a message “Success”
          Downside:
          Both update and delete have same message output

          question: ACTION = “url slug”
          is this possible : action = “pbd_update-thanks”

          Is the action syntax correct

          Sorry I guess I really missing something.
          Thanks and need more support

        16. Make sure you shortcode attributes do not have spaces:

          Won’t work:
          action = "pbd_update-thanks"

          Works:
          action="pbd_update-thanks"

          Also, watch out for curly quotes, the quotes must be straight quotes.

          To have a different message for update and delete, you need a custom template that is designed to tell the difference between the two operations…or use a different “thanks” page for each one. In both cases, you need to have some coding skills, I can’t do that for you.

        17. Hi Roland:

          The action syntax is correct.
          All the while I thought the new delete plugin that you recently modified will take care of the delete message when ever it encountered the “update-thanks” or “pdb_update-thanks” or whatever you call it ???

          Why doesn’t the editable record when saved or submitted behave the same way when a new record has been added. When you add a record and submit it, will ONLY display a message “Record has been ……..” unlike with the editable record when it has been saved, it displays the message including the edited record ?

          I thought when “action=update-thanks” was used it will go to a page and display the update message since w/o it, it includes the message and the edited record but if it was a delete record, the plugin delete will take over and display the delete-message, that’s what I understood when you modified the delete-record plugin ???

          Is there no way for the edit-record to display the update message w/o the edited-record and w/o using the “action=” to go to another page ? since the delete-record message works fine w/o the “action=”

          Can’t you modify or upgrade the edit-record code, so that it does not display the edited record together with the update-message, OR if it displays the edited-record with the update-message, the edited-record is not EDITABLE ???

          I hope you consideration and approval, pls.
          Thank you very much.
          Rdgs;
          javz

        18. I’ve done some testing and I’m sorry to say that the delete plugin can’t show the deletion message if you are using a separate “thanks” page. This is because there is a page refresh and the “thanks” message won’t show if the record can’t be found (the record no longer exists at this point). I never designed the thanks page to work for this situation…I did not realize this until you brought this problem to my attention.

          So, it will be fixed, but not right away, I am working on an update to the main plugin and it will be probably a week before it is ready to release.

          I will also release an update to the pdb-record-delete-switch.php plugin at that time as well.

        19. Thanks Roland:
          I’ll wait for the new plugin and pls. do announce its release.

        20. Hi Roland:
          Any news regarding this:

          You wrote:

          Iā€™ve done some testing and Iā€™m sorry to say that the delete plugin canā€™t show the deletion message if you are using a separate ā€œthanksā€ page. This is because there is a page refresh and the ā€œthanksā€ message wonā€™t show if the record canā€™t be found (the record no longer exists at this point). I never designed the thanks page to work for this situationā€¦I did not realize this until you brought this problem to my attention.

          So, it will be fixed, but not right away, I am working on an update to the main plugin and it will be probably a week before it is ready to release.

          I will also release an update to the pdb-record-delete-switch.php plugin at that time as well.

          Sincerely:
          javz

        21. Yes, you should update to the latest version. There’s an updated version of the record ddelte switch template also.

        22. Dear Roland:
          You Said: ” Yes, you should update to the latest version. Thereā€™s an updated version of the record delete switch template also. ”

          May I know the new file name and where to download ?
          Thank you and regards:
          javz

  3. I finally get it to work but now it shows also “Export CSV..” and file name for exporting all database below all records where link “edit-link” is visible and clickable (using [pdb_list template=edit-link] shrotcode). If I don’t use template (located in ../plugins/participant-database/templates/pdb-list-edit-link.php), I got listed records well, but of course without link at placeholder.

    I am not so proficient in php and stuff and I think I made some error in following your steps.

    1. First of all, make sure you’re putting your template in the correct location,. Do not put your modified templates into the plugin folder, they will be deleted when you update the plugin. The correct place to put the custom template is explained here…

      If you have “Export CSV” showing under the list, you’re probably using the wrong template. The template in this article won’t do that, so you must have gotten your template code from another article….you should use the template code from this article if you want to show a link to the editable record.

      1. Thanks for quick reply. In process of preparing I was doing “Edit record” page, which was translated to local language and therefore slug also changed differently. After I setup all details it still didn’t worked.

        But when I changed also this:
        if ($this->field->name() === ‘edit_link’)
        into
        if ($this->field->name() === ‘change-record’)

        it worked prefectly!

        Thanks for great plugin!

        (I have another question regarding combo search plugin which I will post on different post.)

  4. thanks you too

    1. Hello!
      I did add template and use [pdb_list template=edit-link]. It work well and link point to correct [pdb_record]. Later I install [pdb_user_list] plugin and edit link is not work any more.

      List page
      [pdb_user_list template=edit_link]
      the lis show correct date from user owner but edit link field does not have hyperlink.

      Record Page
      [pdb_record]

      regards,

      1. try renaming your template so it matches the shortcode: pdb-user_list-edit_link.php

      2. ignore my previous message…instead, don’t change the name of your template, then make sure the template name is correct, you have it as edit_link in your second shortcode, should be edit-link

  5. Hello
    I have a little problem.
    I installed participant database to manage the vintage car sheets for a club.
    Each member of the club can have one car or several cars.
    Don I installed the plugin allowing to connect the base to the users.
    shortcode [pdb_user_list] it works well, a user can have multiple cars.

    On the other hand, when I want to apply a template to create a link of modification to each recording of the list created by [pdb_user_list], I click on the link but it is the same car file which opens for all the recording.

    Can you help me?
    Thank you
    Luke

    FYI I apply for all records the shortcode [pdb_list template = edit-link] with the template pdb-list-edit-link.php it works very well

    1. I don’t know what the problem is, hard to tell without seeing it.

      In the pdb-wp-user-shortcode.php script on line 47, you should have:

      return do_shortcode( '[pdb_list filter="' . $this->user_id_field . '=' . $this->user_id() . '" template=edit-link ]' );

      1. Hello
        A big thank-you
        In the definition of the shortcode “pdb-wp-user-shortcodes.php” I was missing “template = edit-link” Here I added it and it works perfectly
        Thank you
        Take care of yourself in this pandemic period
        Luke

  6. Hi,
    I have implemented this and get a list with a clickable link. Clicking on the link opens page example
    https://www.ispotproperty.com.au/prospects-edit/?pid=I8ZMI
    Clicking save saves the record but instead of showing a message returns as 404 page not found error.

    Any help on what I have done wrong here??

    1. It looks like you’re doing everything right. The most likely explanation is that there is a server security rule that is getting triggered by the submission. Ask your web host to look into it, as this is something that is set up at the server configuration level.

  7. Hi When I create new ā€œplaceholderā€ field the option to make read only etc does not appear & when I run [pdb_list template=edit-link] the edit link filed shows just text not clickable.

    1. No need to set the placeholder read-only, they are always read-only. That instruction is from before I changed the UI.

      If the field is not clickable, you need to edit the template so that it targets the correct field. On line 42, it looks for the name of the field to put the link on…this must match the field name you are using to show the link.

      Also, of course, you need to have your Participant Record Page set up.

      1. Hi Roland,

        I have the same problem mentioned above. The edit link isn’t clickable. I add pdb-list-edit-link.php file in my theme folder into a folder named templates and that didn’t work but when I added the files into the folder of the plugin folder worked perfectly. Now I am worried if I update the plugin that file might get wiped out. Can you advise what I need to do please?

        Thanks

        1. The best way to set up custom templates is to use the free Custom Template Folder add-on and then place the templates in this location:

          /wp-content/participants-database-templates/

  8. Hi Roland.
    I used your code from above.
    The list page does give me a edit tab that goes to a pid.
    However, when you click on the edit button, it just clears the page I am on.
    Any thoughts why.
    http://r89.134.myftpupload.com/edit-record-link/
    Drop Down go for Section and enter either “M o J”
    Thank you

    1. Works for me… did you fix it?

      1. Seems to work for me now.
        Thanks for getting back to me.
        Any reason why the burial last name is highlighted in blue? If you click on it, it clears the page. Any way to remove color
        Select burial last name and use “anderose”

        1. The reason the last name is a link is in the plugin setting under the list display tab, check the “Single Record Link Field” also “Single Record Page” settings.

          I suggest you scan through the settings and make sure everything is the way you want it.

          The blue is due to your theme CSS applied to all links. If you want to change it, you need to add your own CSS rules that override it.

  9. Hey Roland. I am very confused with this. I have added a new Field Group called Edit Link. The field title is edit link. Form element is Placeholder. Default Value is Edit. The link shows up but does nothing. My page is Edit DB Record with the shortcode [pdb_list template=edit-link]. I copied your template and added it to the templates folder. I added the field to my Manage Lists Columns.

    I can give you access if you would like.

    James

    1. Check the plugin settings under the “Record Form” tab, make sure the “Participant Record Page” setting points to your page with the [pdb_record] shortcode.

      1. Roland – that didn’t work either. When I click the Edit link it reads “No Record Was Found”.

        Can I email you username and password to look at the settings?

        1. Make sure that the shortcode you have on that page is the [pdb_record] shortcode.

        2. Nothing I seem to do will show records to edit. Looking at what @markdtg has accomplished, I am quite jealous.

          I’m just wondering if I can get help making sure the structure is set up correctly. Thanks!

          James

        3. Send me a link to the list display and I’ll take a look. I’m not usually willing to log in to user’s sites.

  10. Hello fellow colleagues,
    I can’t do that with editing.

    I want the logged in user to be able to edit the data, but how? The howto is very confusing, is there no photo spread?

    Best wishes

    1. Take a look at this page:

      Using Participants Database with WordPress Users

      It explains how to link Participants Database to WordPress users.

Leave a Reply

Your email address will not be published. Required fields are marked *

Would you like to be notified of followup comments via e-mail? You can also subscribe without commenting.

198 thoughts on “Adding an Edit Record Link to the Frontend List

  1. Hi Roland,

    I have created a log list using a custom template based on pdb-log_list-default and placed the get edit link code into the relevant section. Although it is creating a link, it is not pulling the UPID number into the link so returns a page with no record found.

    Is it possible to pull an edit link through the log list?

    1. I’ve turned debugging on and receiving the following error…


      Warning: array_key_exists() expects parameter 2 to be array, null given in /home3/xqxiavmy/public_html/FIPFAclassification/wp-content/plugins/participants-database/classes/PDb_Template.php on line 608

    2. Hi Alex,

      The PDb_Template class can’t be used in a Global Log List template currently, I have it on my to do list, but it’s not implemented yet.

      I have posted an example template that shows how to set the record edit link in a Global Log List with the current version of the Participant Log plugin.

      https://gist.github.com/xnau/9579c48af664cccbf150a92d40655b18

      1. Thank you Roland,

        I’m getting some weird results with the code. From what I can work out it is using the number of log record id to reference the participant private id in participant table. E.g if the log record_id is 6 but is attached to participant id 2, the log_edit_link links to participant id 6 not 2.

        I’m guessing it’s just a case of changing a reference in the function, but I’m still learning so not sure what or where.

        1. A bit of reading and I think I’ve fixed it.
          Line 17 should be
          $record_id = $wpdb->get_var( 'SELECT `record_id` FROM ' . \pdblog\Plugin::log_table_name( $log_list->shortcode_atts['log_name'] ) . ' WHERE `record_id` = "' . $entry_id . '" LIMIT 1' );

          Many thanks again

        2. The code is correct, the “record_id” column of the log entry is the id of the Participants Database record the log entry is attached to. We are using that value to build the record edit URL.

  2. Good day sir,

    How would one go about using this within – pdb-single-default.php for a single link? Or am I missing a simpler way within settings to edit a single record.

    Also, after editing a record and saving, is there a way to have it go back to the [pdb_single]?

    Thank-you,
    Daz

    1. To add an edit link to the single record display, you need to use a custom template. The way to get and apply the link is very similar to the way you do that for a list template. You could also add the link as a separate item (rather than apply it to a PDB field as it is done in the list template).

      To set up a return to the single record after the user edits the record, you will need to use a custom template for the pdb_record shortcode also. You can use the PDb_Template class to get the link back to the single record page, then set the “submission_page” property to that link…you can do that with something like this in the header of the record shortcode custom template:

      $record = new PDb_Template( $this );
      $this->submission_page = $record->get_detail_link();

      1. Thanks for the reply Roland,
        I’m close, I think my problem is where I would place the code on my template. I’m using single_default as the starting point but it wants to repeat the value of the last field.

        Daz

      2. How about changing the redirect page if adding a participant from within admin?

        1. Is it possible to have it redirect to the pdb_single page with the data submitted for the new participant?

        2. You can use the “action” attribute of the [pdb_record] shortcode to send the user to another page after submitting an update.

        3. This is not possible.

        4. Thank-you, I can stop trying and start looking for a work around.
          Appreciate your help, you rock!

      3. Hi Roland:
        How to close the editable-[pdb_record] once the save button is clicked ?
        Just like when the submit button is clicked from the sign-up form..
        Thanks
        rdgs
        javz

        1. You can use the “action” attribute to send them to a different page when they submit the form. Put the [pdb_update_thanks] shortcode on that page to shopw the feedback message.

          [pdb_record action="update-thanks"]

        2. Hi Roland:
          I created a page (Success) w/ shortcode = [pdb_update_thanks] and
          then on the (Record Page), I used the shortcode = [pdb_record action="update-thanks"], but when I clicked the Save Button, it displayed the message “Your information has been updated” (w/c is the default record updated message from the record form settings) and the editable page is still on display… the action=”update-thanks” failed. I also tried to use with [pdb_user_record action=”update-thanks”, but same result, perhaps I missed to set something???

          Help pls. Thanks

        3. The value of the “action” attribute must be the name of the page with the [pdb_update_thanks] sortcode.

          The [pdb_user_record] shortcode does not support the use of the “action” attribute unless you edit the tutorial plugin to use it.

        4. Hi Roland:
          Still on the issue of “action”
          I used [pdb_record action="url slug"] , it worked, its been directed to that page, BUT, unfortunately, if I checked the DELETE checkbox in that editable-page and click the save button, the message “Record has been deleted” was not displayed anymore, only a blank page, How can I display a delete message???
          And this action=”url slug” does work with [pdb_user_record] WHY ?

          Thanks and need help.
          rdgs;javz

        5. It won’t show the deleted message, it’s not set up to do that, I’m sorry. You get a blank page because the record has been deleted, you will need to add some custom code to show a deleted message on that page.

        6. Hi Roland:
          You Said: ” you will need to add some custom code to show a deleted message on that page. ”
          1. HOW and WHERE to add ? Perhaps pdb_record_delete_switch ?
          2. Any similar sample(s) for reference or template?
          Thanks and still need advice.
          Rdgs; Javz

        7. You are using custom code to delete the record. A good way to do this is to add to that code a filter that changes the “thanks” message. The filter for that is pdb-update_thanks_message so you could use something like this:

          <?php add_filter( ‘pdb-update_thanks_message’, function( $message ) { 
             $message = "Your record was deleted.";
             return $message;
           } );  ?>

          For your reference, you can find the filter in the plugin code at around line 390 of classes/PDb_Signup.php

        8. Hi Roland:
          You mean to say that I will Insert this code:

          in pdb-record-delete-switch.php ?

          If YES, which line no. ? Perhaps below line 73 ? where I found the message code :

          if ( $success ) {
          Participants_Db::$plugin_options[‘no_record_error_message’] = __( ‘The record has been deleted.’ );

          Is my understanding correct?

          Thanks, need more advice.
          Rdgs;
          javz

        9. That code should replace the code that sets the “no record error mssage” since you’re providing a different way to show the same message.

        10. Hi Roland:
          I tried to follow your instruction, and came up with this:

          Participants_Db::$plugin_options [add_filter( ā€˜pdb-update_thanks_messageā€™, function( $message ) {
          $message = “Your record was deleted.”;
          return $message;
          } )];

          I did not get any errors with wp, but still it does not display any message when a record has been deleted.

          Is my coding Correct?

          Thanks, and need further advice.
          Rdgs;
          javz

        11. Take a look at the record delete plugin, I updated it with the filter for the thanks page message.

          https://gist.github.com/xnau/40ff2abd35fb856e3d06dbb4bdbc7169

        12. Hi Roland:
          I tried the your new code: pdb-record-delete-switch.php
          1. Installed/activate the plugin and tested it with the existing:
          update-thanks (page) w/ shortcode = [pdb_update_thanks]
          GIPs Record (page) w/ shortcode = [pdb_record action="update-thanks"]

          With update: It displays the message ” [pdb_update_thanks] ”
          With delete: It displays the message ” [pdb_update_thanks] ”

          I checked your new code and notice : add_filter( ‘pdb-update_thanks_message’, function( $message )
          So I changed the page into:
          update-thanks-message (page) w/ shortcode = [pdb_update_thanks_message]
          GIPs Record (page) w/ shortcode = “[pdb_record action="update-thanks-message"]
          But still result….
          So I removed the shortcode from the update_thanks_message (Page)
          It displayed a blank page both on the update and delete pages.

          Did I miss to set something?
          Thanks and need more advice..
          Rdgs;
          javz

        13. Hi Roland:
          I tried the your new code: pdb-record-delete-switch.php
          Installed/activate the plugin and tested it with the existing:
          update-thanks (page) w/ shortcode = [pdb_update_thanks]
          GIP Record (page) w/ shortcode = [pdb_record action="update-thanks"]

          But it displayed the short code instead of the message in both the update and delete pages.

          Did I miss something?
          Thank you and need more advice.

          Rdgs;
          javz

        14. If it shows the shortcode you have one of two issues: either the plugin is not activated or there is a syntax issue with the shortcode string itself. Use a shortcode block and make sure the syntax is correct.

        15. Hi Roland:

          I checked the plugin, its working and activated.
          I check the short code block and syntax, its correct.
          But, still same result, “Blank Message” both for update and delete.

          Remedy:
          I just created a page with a message “Success”
          Downside:
          Both update and delete have same message output

          question: ACTION = “url slug”
          is this possible : action = “pbd_update-thanks”

          Is the action syntax correct

          Sorry I guess I really missing something.
          Thanks and need more support

        16. Make sure you shortcode attributes do not have spaces:

          Won’t work:
          action = "pbd_update-thanks"

          Works:
          action="pbd_update-thanks"

          Also, watch out for curly quotes, the quotes must be straight quotes.

          To have a different message for update and delete, you need a custom template that is designed to tell the difference between the two operations…or use a different “thanks” page for each one. In both cases, you need to have some coding skills, I can’t do that for you.

        17. Hi Roland:

          The action syntax is correct.
          All the while I thought the new delete plugin that you recently modified will take care of the delete message when ever it encountered the “update-thanks” or “pdb_update-thanks” or whatever you call it ???

          Why doesn’t the editable record when saved or submitted behave the same way when a new record has been added. When you add a record and submit it, will ONLY display a message “Record has been ……..” unlike with the editable record when it has been saved, it displays the message including the edited record ?

          I thought when “action=update-thanks” was used it will go to a page and display the update message since w/o it, it includes the message and the edited record but if it was a delete record, the plugin delete will take over and display the delete-message, that’s what I understood when you modified the delete-record plugin ???

          Is there no way for the edit-record to display the update message w/o the edited-record and w/o using the “action=” to go to another page ? since the delete-record message works fine w/o the “action=”

          Can’t you modify or upgrade the edit-record code, so that it does not display the edited record together with the update-message, OR if it displays the edited-record with the update-message, the edited-record is not EDITABLE ???

          I hope you consideration and approval, pls.
          Thank you very much.
          Rdgs;
          javz

        18. I’ve done some testing and I’m sorry to say that the delete plugin can’t show the deletion message if you are using a separate “thanks” page. This is because there is a page refresh and the “thanks” message won’t show if the record can’t be found (the record no longer exists at this point). I never designed the thanks page to work for this situation…I did not realize this until you brought this problem to my attention.

          So, it will be fixed, but not right away, I am working on an update to the main plugin and it will be probably a week before it is ready to release.

          I will also release an update to the pdb-record-delete-switch.php plugin at that time as well.

        19. Thanks Roland:
          I’ll wait for the new plugin and pls. do announce its release.

        20. Hi Roland:
          Any news regarding this:

          You wrote:

          Iā€™ve done some testing and Iā€™m sorry to say that the delete plugin canā€™t show the deletion message if you are using a separate ā€œthanksā€ page. This is because there is a page refresh and the ā€œthanksā€ message wonā€™t show if the record canā€™t be found (the record no longer exists at this point). I never designed the thanks page to work for this situationā€¦I did not realize this until you brought this problem to my attention.

          So, it will be fixed, but not right away, I am working on an update to the main plugin and it will be probably a week before it is ready to release.

          I will also release an update to the pdb-record-delete-switch.php plugin at that time as well.

          Sincerely:
          javz

        21. Yes, you should update to the latest version. There’s an updated version of the record ddelte switch template also.

        22. Dear Roland:
          You Said: ” Yes, you should update to the latest version. Thereā€™s an updated version of the record delete switch template also. ”

          May I know the new file name and where to download ?
          Thank you and regards:
          javz

  3. I finally get it to work but now it shows also “Export CSV..” and file name for exporting all database below all records where link “edit-link” is visible and clickable (using [pdb_list template=edit-link] shrotcode). If I don’t use template (located in ../plugins/participant-database/templates/pdb-list-edit-link.php), I got listed records well, but of course without link at placeholder.

    I am not so proficient in php and stuff and I think I made some error in following your steps.

    1. First of all, make sure you’re putting your template in the correct location,. Do not put your modified templates into the plugin folder, they will be deleted when you update the plugin. The correct place to put the custom template is explained here…

      If you have “Export CSV” showing under the list, you’re probably using the wrong template. The template in this article won’t do that, so you must have gotten your template code from another article….you should use the template code from this article if you want to show a link to the editable record.

      1. Thanks for quick reply. In process of preparing I was doing “Edit record” page, which was translated to local language and therefore slug also changed differently. After I setup all details it still didn’t worked.

        But when I changed also this:
        if ($this->field->name() === ‘edit_link’)
        into
        if ($this->field->name() === ‘change-record’)

        it worked prefectly!

        Thanks for great plugin!

        (I have another question regarding combo search plugin which I will post on different post.)

  4. thanks you too

    1. Hello!
      I did add template and use [pdb_list template=edit-link]. It work well and link point to correct [pdb_record]. Later I install [pdb_user_list] plugin and edit link is not work any more.

      List page
      [pdb_user_list template=edit_link]
      the lis show correct date from user owner but edit link field does not have hyperlink.

      Record Page
      [pdb_record]

      regards,

      1. try renaming your template so it matches the shortcode: pdb-user_list-edit_link.php

      2. ignore my previous message…instead, don’t change the name of your template, then make sure the template name is correct, you have it as edit_link in your second shortcode, should be edit-link

  5. Hello
    I have a little problem.
    I installed participant database to manage the vintage car sheets for a club.
    Each member of the club can have one car or several cars.
    Don I installed the plugin allowing to connect the base to the users.
    shortcode [pdb_user_list] it works well, a user can have multiple cars.

    On the other hand, when I want to apply a template to create a link of modification to each recording of the list created by [pdb_user_list], I click on the link but it is the same car file which opens for all the recording.

    Can you help me?
    Thank you
    Luke

    FYI I apply for all records the shortcode [pdb_list template = edit-link] with the template pdb-list-edit-link.php it works very well

    1. I don’t know what the problem is, hard to tell without seeing it.

      In the pdb-wp-user-shortcode.php script on line 47, you should have:

      return do_shortcode( '[pdb_list filter="' . $this->user_id_field . '=' . $this->user_id() . '" template=edit-link ]' );

      1. Hello
        A big thank-you
        In the definition of the shortcode “pdb-wp-user-shortcodes.php” I was missing “template = edit-link” Here I added it and it works perfectly
        Thank you
        Take care of yourself in this pandemic period
        Luke

  6. Hi,
    I have implemented this and get a list with a clickable link. Clicking on the link opens page example
    https://www.ispotproperty.com.au/prospects-edit/?pid=I8ZMI
    Clicking save saves the record but instead of showing a message returns as 404 page not found error.

    Any help on what I have done wrong here??

    1. It looks like you’re doing everything right. The most likely explanation is that there is a server security rule that is getting triggered by the submission. Ask your web host to look into it, as this is something that is set up at the server configuration level.

  7. Hi When I create new ā€œplaceholderā€ field the option to make read only etc does not appear & when I run [pdb_list template=edit-link] the edit link filed shows just text not clickable.

    1. No need to set the placeholder read-only, they are always read-only. That instruction is from before I changed the UI.

      If the field is not clickable, you need to edit the template so that it targets the correct field. On line 42, it looks for the name of the field to put the link on…this must match the field name you are using to show the link.

      Also, of course, you need to have your Participant Record Page set up.

      1. Hi Roland,

        I have the same problem mentioned above. The edit link isn’t clickable. I add pdb-list-edit-link.php file in my theme folder into a folder named templates and that didn’t work but when I added the files into the folder of the plugin folder worked perfectly. Now I am worried if I update the plugin that file might get wiped out. Can you advise what I need to do please?

        Thanks

        1. The best way to set up custom templates is to use the free Custom Template Folder add-on and then place the templates in this location:

          /wp-content/participants-database-templates/

  8. Hi Roland.
    I used your code from above.
    The list page does give me a edit tab that goes to a pid.
    However, when you click on the edit button, it just clears the page I am on.
    Any thoughts why.
    http://r89.134.myftpupload.com/edit-record-link/
    Drop Down go for Section and enter either “M o J”
    Thank you

    1. Works for me… did you fix it?

      1. Seems to work for me now.
        Thanks for getting back to me.
        Any reason why the burial last name is highlighted in blue? If you click on it, it clears the page. Any way to remove color
        Select burial last name and use “anderose”

        1. The reason the last name is a link is in the plugin setting under the list display tab, check the “Single Record Link Field” also “Single Record Page” settings.

          I suggest you scan through the settings and make sure everything is the way you want it.

          The blue is due to your theme CSS applied to all links. If you want to change it, you need to add your own CSS rules that override it.

  9. Hey Roland. I am very confused with this. I have added a new Field Group called Edit Link. The field title is edit link. Form element is Placeholder. Default Value is Edit. The link shows up but does nothing. My page is Edit DB Record with the shortcode [pdb_list template=edit-link]. I copied your template and added it to the templates folder. I added the field to my Manage Lists Columns.

    I can give you access if you would like.

    James

    1. Check the plugin settings under the “Record Form” tab, make sure the “Participant Record Page” setting points to your page with the [pdb_record] shortcode.

      1. Roland – that didn’t work either. When I click the Edit link it reads “No Record Was Found”.

        Can I email you username and password to look at the settings?

        1. Make sure that the shortcode you have on that page is the [pdb_record] shortcode.

        2. Nothing I seem to do will show records to edit. Looking at what @markdtg has accomplished, I am quite jealous.

          I’m just wondering if I can get help making sure the structure is set up correctly. Thanks!

          James

        3. Send me a link to the list display and I’ll take a look. I’m not usually willing to log in to user’s sites.

  10. Hello fellow colleagues,
    I can’t do that with editing.

    I want the logged in user to be able to edit the data, but how? The howto is very confusing, is there no photo spread?

    Best wishes

    1. Take a look at this page:

      Using Participants Database with WordPress Users

      It explains how to link Participants Database to WordPress users.

Leave a Reply

Your email address will not be published. Required fields are marked *

Would you like to be notified of followup comments via e-mail? You can also subscribe without commenting.