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.

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

  1. Hi,

    Thanks so much for this – I have successfully combined this with the tutorial on creating a list of records by user_login. This list has working edit links which take you to the front-end edit record page.

    However, clicking submit after making changes takes the user to a 404 page. Mostly the changes are not saved, although on a couple of occasions they did indeed save but I can’t see what I did differently (the result was a 404 all the same). I tried an “action=” in the shortcode to determine a thanks page, following your other tutorial, but it didn’t work either.

    I have flushed the permalinks settings but to no avail. Could you suggest anything else?

    Many thanks,

    Neil

    1. Hi Neil,

      This looks like you’re hitting a security filter on your server. I would suggest you contact your web host about this, they will be able to tell what’s happening and put in an exception to allow the record to be updated.

      1. OK thanks I’ve contacted them – fingers crossed.

        1. I contacted the web host and they say as it’s a 404 not a 403 error, it’s unlikely that it’s at their end. They add: “There’s nothing setup by default on our Simple Hosting platform that would prevent PHP code from updating a database entry – it’s a pretty standard operation.” I can look at the PHP logs but I’m not sure what I’m looking for.

          I’ve done some more testing and indeed editing does work with some records, now going to the Thanks page and triggering the email. However, not with others. It *seems* like it doesn’t work with recently added records for testing purposes (whether approved or not), but it does with existing records. I imported most of the database from another system then filled the “user_login” fields in the back end to match our wp user names. I’ll continue testing but this might be a clue to what’s happening.

  2. This edit-link had set up and worked perfectly, but now for the life of me I cannot get the edit_link field to be clickable again in the list display.
    It displays default value of Edit, but is not clickable.
    Using correct custom edit-link template as provided (thanks Roland) with no custom code in. Database edit_link field setup as Text-line, Values = https://www link to my page that has [pdb_records] shortcode in….. not creating a link.
    In Settings> Record Form>Participant Record Page is set to same page.
    The Link field to the single record in the list display works fine.
    WP4.8.1 with latest Plugin update.

    1. Can you provide a link so I can see what it’s doing?

  3. Hi I am having problems trying to link to the [pdb_records] page it keeps going to the [pdb_single] can you please explain what I have done
    Many thanks
    Christine

    1. Hi Christine,

      Which page this goes to is determined by the “Participant Record Page” setting in the plugin settings under the “record form” tab. Make sure that is a page with the [pdb_record] shortcode on it.

      1. Hi thanks for your time, I have done that and deleted the page and redone it again but the list links to [pdb_single] and the fields are uneditable. I have just got stuck on this bit everything else has worked on your brilliant plugin
        many thanks
        Christine

        1. OK, check to make sure you are placing your edit record links on the correct field in your list. It sounds like you’re clicking on the single record link. Put your record edit link on a different field or put your single record links on a different field so they don’t interfere with each other.

      2. Hi thank you, I have added new pages and put the relevant shortcodes and linked them up in the appropriate settings and still not working. Its probably something stupid that I have done. Could you please show me an example of a working custom template for the Edit Record Link to the Frontend List, then maybe I could work it out. many thanks Christine

        1. There is a full template in the article. You can just download it and use it as-is. the only thing you may need to change is the name of the field that your link is going on. In the template it is on line 42, ‘edit-link’ just change that to the name of the field you want your link to go on. The rest is just a matter of correctly configuring the plugin.

          pdb-list-edit-link.php

        2. Thank you I thought that I followed your instructions, I have used that template just not working as it keeps linking to the [pbd_single]. I am sorry do you mean the field on the form, not the page obviously. As i said everything else is working. All the shortcodes are on separate pages. I will try to do it again. best wishes, Christine

      3. how can i change default output form in pdb-record

  4. Hi Roland,

    I’m working on a site and your plugin has helped a lot with adding the database capabilities for users to create and edit records. I do not have experience in sql or php so this was a major help! Thank you!

    I am working on allowing users to edit their record and can not enable the edit link. If you have a minute can you check out the code and see what I’m missing? THANK YOU!

    (Copied exactly from your custom template. Added the ‘recordslisttest’ page into the ” $record->get_edit_link(‘recordslisttest’) ” section.

    Template file is located at: public_html/wp-content/themes/colormag/page-templates/

    Uploaded the file named: pdb-list-edit-link.php

    “edit_link” field is under the “national_parks” field group. Settings for “edit_link” are Title: “Edit Link”, Default:”edit”, Group: “national_parks”, Help Text – blank, Form Element: “Text-Line”, Values – Blank, Required, Display Column: 1, Admin Column: 1, Read Only is the only box checked.

    Record Form Settings in points to the Recordlisttest page.

    http://www.featster.com/recordlisttest has the following:

    [pdb_record]

    [insert_php]
    global $current_user;
    echo do_shortcode(‘[pdb_list template=edit-link . groups="national_parks" . filter="user_login=' . $current_user->user_login . '"]‘);
    [/insert_php]

    [pdb_list template=edit-link]

    1. Hi Paul,

      OK, I took the code out, it was too garbled. This forum doesn’t do code well, unfortunately.

      The first issue I see is that you don’t have the template in the right place, so the plugin isn’t finding it. Your template should be in

      public_html/wp-content/themes/colormag/templates/

      Second, your PHP syntax is incorrect in your page, should be something like this:

      [insert_php]
      global $current_user;
      echo do_shortcode(‘[pdb_list template=edit-link groups=”national_parks” filter=”user_login=’ . $current_user->user_login . ‘”]‘);
      [/insert_php]

      Leave out the other two shortcodes you had.

      1. Hi Roland,

        I created a folder in the colormag theme titled “templates” and moved the pdb-list-edit-link.php file there.
        public_html/wp-content/themes/colormag/templates

        I also deleted the other shortcodes and entered the php you listed above.

        I’m sure it’s closer to being there but now does not display anything in the page space.

        Reading the comments I noticed the permalink reference. I do not have a permalink plugin but do have the permalinks within the wordpress settings set to custom: http://featster.com /%author%/%postname%/

        Also by deleting the [pdb_record] shortcode from the http://www.featster.com/recordlisttest page the shortcode is no longer on the page which is mentioned under the settings: The page where your participant record ([pdb_record] shortcode) is displayed.

        Thanks for the help and advice on this.

        1. OK, I’m a bit confused here as to what problem you’re actually having. I’d suggest you go through the “Quick Setup Guide” to get your basic setup, then focus on your list with the custom template. Once you’ve done that, let me know what is happening on the list page if it is still not working.

        2. Will do! I’m hoping eventually to make a list of user entries on their park visits. Basically a log of their adventures which they can view and edit.

          I was looking to use the group listed in:

          [insert_php]
          global $current_user;
          echo do_shortcode(‘[pdb_list template=edit-link group=”national_parks” filter=”user_login=’ . $current_user->user_login . ‘”]‘);
          [/insert_php]

          I set up a signup page with just the National Parks group. From there I have gotten it to where users can log their visit and view it. But they can’t edit or delete any of the entries, which would be nice to have.

          Anyway, I’ll go through the guides some more and see if I can get it dialed. Thanks for your time!

          Paul

        3. Should mention that I am able to get the user to see a list of all of their park entries via:

          [insert_php]
          global $current_user;
          echo do_shortcode(‘[pdb_list filter="user_login=' . $current_user->user_login . '"]‘);
          [/insert_php]

          But when the user clicks on their private link they are only able to edit the Sign-up form and not the list that shows all of their user entries.

          Edit Link Date of Visit National Park user_login State Country
          edit September 2, 2015 Zion Featster CA USA
          edit February 3, 2015 Zion Featster CA USA
          edit September 2, 2014 Zion Featster CA USA
          edit August 2, 2016 Zion Featster CA USA
          edit February 2, 2016 Zion Featster CA USA
          edit September 2, 2016 Bryce Canyon Featster CA USA
          edit August 20, 2016 Bryce Canyon Featster CA USA
          edit February 2, 2014 Lassen Featster CA USA
          edit February 2, 2015 Lassen Featster CA USA
          edit June 3, 2016 Zion Featster CA USA

        4. If you follow the setup guide it will work, You probably have the wrong shortcode on your “record edit page” it should be the [pdb_record] shortcode.

    1. sorry, the code gets executed.. its on the hyperlink that i wanted to add special class to.

      1. I can’t explain fully, but you need to add something like this to your custom template:

        <?php if ( $this->field->is_single_record_link() ) {
        $this->field->attributes['rel'] = 'nofollow';
        } ?>

        That is the correct way to add an attribute to your single record link.

        1. Hi, What i am trying to achieve is;

          to add css styles on the link that i choose to be the single_record_link

          example this is my html output from inspect

          John Hartman

          I can achieve to add it on the “td” class but not to the “a href” which is where i want to put my custom code.

          Thanks.

        2. i’m sorry i make a mess of this comment, how do you insert code in the comment?

          ~td class=”first-field”~
          ~a href=”https://mywebsite.com/member-details/?pdb=143″ class=”new-css-style”~ John Hartman~/a
          ~/td~

          i just replaced < with ~ :D

          Again sorry.

        3. Usually, you don’t need to add a class to the link like that, you can use the class of a wrapping element. If that isn’t possible, then you may need to add a class, but I did show you how to do that if you realize that a class is just another attribute.

          <?php if ( $this->field->is_single_record_link() ) {
          $this->field->attributes[‘class’] = ‘single-record-link’;
          } ?>

  5. Roland – did you get a chance to look at the template I sent you.

    This still isn’t working for me.

    if ($this->field->name == ‘edit_link’)
    {
    $this->field->link = $record->get_edit_link(‘test’);
    }
    $this->field->print_value();

    I believe this should provide a link to the edit record page titled test – it doesn’t, it always takes me to the default edit record page

    I really do need to use alternate record edit pages for different purposes

    Malcolm

    1. I got your template, there’s nothing wrong with it, so the only thing I can think of is there is something up with the page named “edit” make sure the slug is correct and that the page is published.

      1. Roland, thanks for your help and various suggestions. I have finally got this to work – the problem appears to be related to permalinks. Turning “Enable Permalinks on Record Edit URLs” OFF in the permalinks settings makes the routine work.

        1. I didn’t know you were using the permalinks add-on. That could probably also be solved by refreshing the WP permalinks in the general settings menu.

  6. I am trying to use a custom edit page but can’t seem to get it to work. Where in the custom template do I put the $record->get_edit_link(‘record-edit’) to get the Edit link to go to “Record-Edit” page?

    1. Malcolm,

      if you are building your own custom template, you’ll need to look at the example here and see the overall pattern of how it works. There are certain functions that will be the same in all templates… for instance all list templates will have:

      while ( $this->have_records() ) : $this->the_record();

      That sets up the record for each one in the list. You need to instantiate the PDb_Template class right after that so that it contains the data from that record. Once you’ve done that, you can use your method. You can see how this is done in the example, so all you need to do is follow the pattern in your template.

    2. Roland,

      I have followed the example to the letter and all is fine except I cannot get the “Edit Record” link to link to a different edit page

      My code is

      field->name == ‘edit_link’)
      {
      $this->field->link = $record->get_edit_link(‘admin-contact-edit’);
      }
      $this->field->print_value();
      ?>

      I want the link to take me to admin-contact-edit not the default edit page which is what is happening

      Malcolm

    3. Ah, now I get it. This should be working. Of course, make sure the slug is correct, the plugin defaults back to the global setting if the permalink for the designated page can’t be found. If your site has a complex page hierarchy, you may need to add more of the path to the page designation.

      I hope the code in your template includes the full “if” statement…what you pasted there won’t work as-is.

    4. Roland,

      RE: $record->get_edit_link(‘test’)

      This isn’t working and I have no idea why. I have checked it with a very simple top level slug “test” with [pdb_record fields="side_name"] on the test page. The link produced still takes me to the default record edit page.

      1. I assume you have the latest plugin version…

        You can also use the post ID, see if that works.

        1. Yes I have latest version of plugin, and No – post ID (just the post id number?) isn’t working with it either. I am running out of time tonight and away for a week first thing in the morning – I will pick up on this when I get back next week

        2. OK, well when you get a minute, email the template to me, I suspect the problem is there.

  7. This is a great plugin! I only have a small inquiry, I appreciate your work Mr. Roland, and I’d like to purchase the groups tabs plugin, Already have it my cart, just one question: How can I create two edit links for one record? – – – For instance I have a very long record, separated in groups – each group has a its own signup form page, and it’s own custom out-put page. I customized the single-record template to output only fields related to the sign-up group on a specific page. Now I am in need to providing the user with the ability to edit a specific GROUP of fields in Such as if I have “Main, Personal Data, Record data”, I want them to be able to edit record data alone, another different user to be able to edit main alone. How do I get to show more than one edit link in the list display table. each corresponding to a specific group record for editing. (I have already created specific group edit pages (such as [pdb_record groups="main"] etc).

    I thank you so much for the support,

    Regards,
    PHILIP.

    1. I used custom template for single record – with a unique edit link and unique record edit page as explain above. Thank you so much for the clear tutorial.

      One more question, How can I display the signup form in a custom way – with specific fields in custom positions? Your tutorial on customizing the single record output was so clear and it has been so helpful to us, we can easily modify the order of fields within the template – but there’s no we can do the same for the sign-up form template, such that it does not display in loops. We’d gladly appreciate your help. Thank you so much in advance.

      Regards,
      Philip.

      1. I don’t have a tutorial to show you an example, I’m sorry, but it will work mostly the same, except instead of using the $record->print_field( $name ); method, you use the $record->print_form_element( $name ) method that prints the form field.

        1. Will definitely try this out. Thank you so much for your time and for this great plugin. we appreciate.

        2. Thank you so much for the help, just got stuck here:

          I was able to use the code above to make a custom display of a record for editing, but I am failing to get the submit button to work. It exists but it does not submit edited data. Kindly advice where am wrong. Here is the code:

          Space Code:print_field('id') ?>
          Item:print_form_element('item') ?>
          Consigneeprint_form_element('consignee') ?>
          Ware House No.print_form_element('wh_entry_no') ?>
          Rate/Dayprint_form_element('rate') ?>
          Invoice Dateprint_form_element('invoice_date') ?>

          SAVE RECORDS

          print_submit_button('button-primary');


          print_form_close() ?>

        3. woa, my code has been stripped: but the submit button code is: $this->print_submit_button('button-primary');

        4. Compare your custom template to the default template. Make sure all the parts are there…especially the $this->print_form_head() function call.

        5. Great!! This has worked-out just fine. Thank you so much!

    2. Hi Philip,

      There are several approaches you could try. One would be to replace the $record->get_edit_link() with code that builds the specific edit link you want for that field.

      First, you’d have your [pdb_record] shortcodes on different pages so that each one edits a different set of fields. You can do this in the shortcode like this: [pdb_record fields="main"]

      Now for each edit link you want to build, you need to construct the link something like this:

      $this->field->link = get_permalink('main-edit') . '?pid=' . $record->get_value('private_id');

      ‘main-edit’ in this example is the name of the page with the [pdb_record fields="main"] shortcode on it. You can do that for as many different group edit pages as you want.

      1. This is so helpful! We’ve been able to implement it on two major groups of fields. Thank you so much Mr. Roland.

        Any ideas concerning the second inquiry above? How we can modify the signup output template to display exactly what we want were we want it e.g. within several columned tables, rather than using loops, etc like it is with the pdb_single template (just as you showed it in a Chrystal clear tutorial –> https://xnau.com/using-the-pdb_template-class-in-your-custom-templates/ Can the same idea be applied to the signup templates? Thank you so much,

        Regards,
        Philip.

  8. Anyway of putting this into a plugin?

  9. […] You may want to combine this with: Adding an Edit Record Link to the Frontend List […]

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.

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

  1. Hi,

    Thanks so much for this – I have successfully combined this with the tutorial on creating a list of records by user_login. This list has working edit links which take you to the front-end edit record page.

    However, clicking submit after making changes takes the user to a 404 page. Mostly the changes are not saved, although on a couple of occasions they did indeed save but I can’t see what I did differently (the result was a 404 all the same). I tried an “action=” in the shortcode to determine a thanks page, following your other tutorial, but it didn’t work either.

    I have flushed the permalinks settings but to no avail. Could you suggest anything else?

    Many thanks,

    Neil

    1. Hi Neil,

      This looks like you’re hitting a security filter on your server. I would suggest you contact your web host about this, they will be able to tell what’s happening and put in an exception to allow the record to be updated.

      1. OK thanks I’ve contacted them – fingers crossed.

        1. I contacted the web host and they say as it’s a 404 not a 403 error, it’s unlikely that it’s at their end. They add: “There’s nothing setup by default on our Simple Hosting platform that would prevent PHP code from updating a database entry – it’s a pretty standard operation.” I can look at the PHP logs but I’m not sure what I’m looking for.

          I’ve done some more testing and indeed editing does work with some records, now going to the Thanks page and triggering the email. However, not with others. It *seems* like it doesn’t work with recently added records for testing purposes (whether approved or not), but it does with existing records. I imported most of the database from another system then filled the “user_login” fields in the back end to match our wp user names. I’ll continue testing but this might be a clue to what’s happening.

  2. This edit-link had set up and worked perfectly, but now for the life of me I cannot get the edit_link field to be clickable again in the list display.
    It displays default value of Edit, but is not clickable.
    Using correct custom edit-link template as provided (thanks Roland) with no custom code in. Database edit_link field setup as Text-line, Values = https://www link to my page that has [pdb_records] shortcode in….. not creating a link.
    In Settings> Record Form>Participant Record Page is set to same page.
    The Link field to the single record in the list display works fine.
    WP4.8.1 with latest Plugin update.

    1. Can you provide a link so I can see what it’s doing?

  3. Hi I am having problems trying to link to the [pdb_records] page it keeps going to the [pdb_single] can you please explain what I have done
    Many thanks
    Christine

    1. Hi Christine,

      Which page this goes to is determined by the “Participant Record Page” setting in the plugin settings under the “record form” tab. Make sure that is a page with the [pdb_record] shortcode on it.

      1. Hi thanks for your time, I have done that and deleted the page and redone it again but the list links to [pdb_single] and the fields are uneditable. I have just got stuck on this bit everything else has worked on your brilliant plugin
        many thanks
        Christine

        1. OK, check to make sure you are placing your edit record links on the correct field in your list. It sounds like you’re clicking on the single record link. Put your record edit link on a different field or put your single record links on a different field so they don’t interfere with each other.

      2. Hi thank you, I have added new pages and put the relevant shortcodes and linked them up in the appropriate settings and still not working. Its probably something stupid that I have done. Could you please show me an example of a working custom template for the Edit Record Link to the Frontend List, then maybe I could work it out. many thanks Christine

        1. There is a full template in the article. You can just download it and use it as-is. the only thing you may need to change is the name of the field that your link is going on. In the template it is on line 42, ‘edit-link’ just change that to the name of the field you want your link to go on. The rest is just a matter of correctly configuring the plugin.

          pdb-list-edit-link.php

        2. Thank you I thought that I followed your instructions, I have used that template just not working as it keeps linking to the [pbd_single]. I am sorry do you mean the field on the form, not the page obviously. As i said everything else is working. All the shortcodes are on separate pages. I will try to do it again. best wishes, Christine

      3. how can i change default output form in pdb-record

  4. Hi Roland,

    I’m working on a site and your plugin has helped a lot with adding the database capabilities for users to create and edit records. I do not have experience in sql or php so this was a major help! Thank you!

    I am working on allowing users to edit their record and can not enable the edit link. If you have a minute can you check out the code and see what I’m missing? THANK YOU!

    (Copied exactly from your custom template. Added the ‘recordslisttest’ page into the ” $record->get_edit_link(‘recordslisttest’) ” section.

    Template file is located at: public_html/wp-content/themes/colormag/page-templates/

    Uploaded the file named: pdb-list-edit-link.php

    “edit_link” field is under the “national_parks” field group. Settings for “edit_link” are Title: “Edit Link”, Default:”edit”, Group: “national_parks”, Help Text – blank, Form Element: “Text-Line”, Values – Blank, Required, Display Column: 1, Admin Column: 1, Read Only is the only box checked.

    Record Form Settings in points to the Recordlisttest page.

    http://www.featster.com/recordlisttest has the following:

    [pdb_record]

    [insert_php]
    global $current_user;
    echo do_shortcode(‘[pdb_list template=edit-link . groups="national_parks" . filter="user_login=' . $current_user->user_login . '"]‘);
    [/insert_php]

    [pdb_list template=edit-link]

    1. Hi Paul,

      OK, I took the code out, it was too garbled. This forum doesn’t do code well, unfortunately.

      The first issue I see is that you don’t have the template in the right place, so the plugin isn’t finding it. Your template should be in

      public_html/wp-content/themes/colormag/templates/

      Second, your PHP syntax is incorrect in your page, should be something like this:

      [insert_php]
      global $current_user;
      echo do_shortcode(‘[pdb_list template=edit-link groups=”national_parks” filter=”user_login=’ . $current_user->user_login . ‘”]‘);
      [/insert_php]

      Leave out the other two shortcodes you had.

      1. Hi Roland,

        I created a folder in the colormag theme titled “templates” and moved the pdb-list-edit-link.php file there.
        public_html/wp-content/themes/colormag/templates

        I also deleted the other shortcodes and entered the php you listed above.

        I’m sure it’s closer to being there but now does not display anything in the page space.

        Reading the comments I noticed the permalink reference. I do not have a permalink plugin but do have the permalinks within the wordpress settings set to custom: http://featster.com /%author%/%postname%/

        Also by deleting the [pdb_record] shortcode from the http://www.featster.com/recordlisttest page the shortcode is no longer on the page which is mentioned under the settings: The page where your participant record ([pdb_record] shortcode) is displayed.

        Thanks for the help and advice on this.

        1. OK, I’m a bit confused here as to what problem you’re actually having. I’d suggest you go through the “Quick Setup Guide” to get your basic setup, then focus on your list with the custom template. Once you’ve done that, let me know what is happening on the list page if it is still not working.

        2. Will do! I’m hoping eventually to make a list of user entries on their park visits. Basically a log of their adventures which they can view and edit.

          I was looking to use the group listed in:

          [insert_php]
          global $current_user;
          echo do_shortcode(‘[pdb_list template=edit-link group=”national_parks” filter=”user_login=’ . $current_user->user_login . ‘”]‘);
          [/insert_php]

          I set up a signup page with just the National Parks group. From there I have gotten it to where users can log their visit and view it. But they can’t edit or delete any of the entries, which would be nice to have.

          Anyway, I’ll go through the guides some more and see if I can get it dialed. Thanks for your time!

          Paul

        3. Should mention that I am able to get the user to see a list of all of their park entries via:

          [insert_php]
          global $current_user;
          echo do_shortcode(‘[pdb_list filter="user_login=' . $current_user->user_login . '"]‘);
          [/insert_php]

          But when the user clicks on their private link they are only able to edit the Sign-up form and not the list that shows all of their user entries.

          Edit Link Date of Visit National Park user_login State Country
          edit September 2, 2015 Zion Featster CA USA
          edit February 3, 2015 Zion Featster CA USA
          edit September 2, 2014 Zion Featster CA USA
          edit August 2, 2016 Zion Featster CA USA
          edit February 2, 2016 Zion Featster CA USA
          edit September 2, 2016 Bryce Canyon Featster CA USA
          edit August 20, 2016 Bryce Canyon Featster CA USA
          edit February 2, 2014 Lassen Featster CA USA
          edit February 2, 2015 Lassen Featster CA USA
          edit June 3, 2016 Zion Featster CA USA

        4. If you follow the setup guide it will work, You probably have the wrong shortcode on your “record edit page” it should be the [pdb_record] shortcode.

    1. sorry, the code gets executed.. its on the hyperlink that i wanted to add special class to.

      1. I can’t explain fully, but you need to add something like this to your custom template:

        <?php if ( $this->field->is_single_record_link() ) {
        $this->field->attributes['rel'] = 'nofollow';
        } ?>

        That is the correct way to add an attribute to your single record link.

        1. Hi, What i am trying to achieve is;

          to add css styles on the link that i choose to be the single_record_link

          example this is my html output from inspect

          John Hartman

          I can achieve to add it on the “td” class but not to the “a href” which is where i want to put my custom code.

          Thanks.

        2. i’m sorry i make a mess of this comment, how do you insert code in the comment?

          ~td class=”first-field”~
          ~a href=”https://mywebsite.com/member-details/?pdb=143″ class=”new-css-style”~ John Hartman~/a
          ~/td~

          i just replaced < with ~ :D

          Again sorry.

        3. Usually, you don’t need to add a class to the link like that, you can use the class of a wrapping element. If that isn’t possible, then you may need to add a class, but I did show you how to do that if you realize that a class is just another attribute.

          <?php if ( $this->field->is_single_record_link() ) {
          $this->field->attributes[‘class’] = ‘single-record-link’;
          } ?>

  5. Roland – did you get a chance to look at the template I sent you.

    This still isn’t working for me.

    if ($this->field->name == ‘edit_link’)
    {
    $this->field->link = $record->get_edit_link(‘test’);
    }
    $this->field->print_value();

    I believe this should provide a link to the edit record page titled test – it doesn’t, it always takes me to the default edit record page

    I really do need to use alternate record edit pages for different purposes

    Malcolm

    1. I got your template, there’s nothing wrong with it, so the only thing I can think of is there is something up with the page named “edit” make sure the slug is correct and that the page is published.

      1. Roland, thanks for your help and various suggestions. I have finally got this to work – the problem appears to be related to permalinks. Turning “Enable Permalinks on Record Edit URLs” OFF in the permalinks settings makes the routine work.

        1. I didn’t know you were using the permalinks add-on. That could probably also be solved by refreshing the WP permalinks in the general settings menu.

  6. I am trying to use a custom edit page but can’t seem to get it to work. Where in the custom template do I put the $record->get_edit_link(‘record-edit’) to get the Edit link to go to “Record-Edit” page?

    1. Malcolm,

      if you are building your own custom template, you’ll need to look at the example here and see the overall pattern of how it works. There are certain functions that will be the same in all templates… for instance all list templates will have:

      while ( $this->have_records() ) : $this->the_record();

      That sets up the record for each one in the list. You need to instantiate the PDb_Template class right after that so that it contains the data from that record. Once you’ve done that, you can use your method. You can see how this is done in the example, so all you need to do is follow the pattern in your template.

    2. Roland,

      I have followed the example to the letter and all is fine except I cannot get the “Edit Record” link to link to a different edit page

      My code is

      field->name == ‘edit_link’)
      {
      $this->field->link = $record->get_edit_link(‘admin-contact-edit’);
      }
      $this->field->print_value();
      ?>

      I want the link to take me to admin-contact-edit not the default edit page which is what is happening

      Malcolm

    3. Ah, now I get it. This should be working. Of course, make sure the slug is correct, the plugin defaults back to the global setting if the permalink for the designated page can’t be found. If your site has a complex page hierarchy, you may need to add more of the path to the page designation.

      I hope the code in your template includes the full “if” statement…what you pasted there won’t work as-is.

    4. Roland,

      RE: $record->get_edit_link(‘test’)

      This isn’t working and I have no idea why. I have checked it with a very simple top level slug “test” with [pdb_record fields="side_name"] on the test page. The link produced still takes me to the default record edit page.

      1. I assume you have the latest plugin version…

        You can also use the post ID, see if that works.

        1. Yes I have latest version of plugin, and No – post ID (just the post id number?) isn’t working with it either. I am running out of time tonight and away for a week first thing in the morning – I will pick up on this when I get back next week

        2. OK, well when you get a minute, email the template to me, I suspect the problem is there.

  7. This is a great plugin! I only have a small inquiry, I appreciate your work Mr. Roland, and I’d like to purchase the groups tabs plugin, Already have it my cart, just one question: How can I create two edit links for one record? – – – For instance I have a very long record, separated in groups – each group has a its own signup form page, and it’s own custom out-put page. I customized the single-record template to output only fields related to the sign-up group on a specific page. Now I am in need to providing the user with the ability to edit a specific GROUP of fields in Such as if I have “Main, Personal Data, Record data”, I want them to be able to edit record data alone, another different user to be able to edit main alone. How do I get to show more than one edit link in the list display table. each corresponding to a specific group record for editing. (I have already created specific group edit pages (such as [pdb_record groups="main"] etc).

    I thank you so much for the support,

    Regards,
    PHILIP.

    1. I used custom template for single record – with a unique edit link and unique record edit page as explain above. Thank you so much for the clear tutorial.

      One more question, How can I display the signup form in a custom way – with specific fields in custom positions? Your tutorial on customizing the single record output was so clear and it has been so helpful to us, we can easily modify the order of fields within the template – but there’s no we can do the same for the sign-up form template, such that it does not display in loops. We’d gladly appreciate your help. Thank you so much in advance.

      Regards,
      Philip.

      1. I don’t have a tutorial to show you an example, I’m sorry, but it will work mostly the same, except instead of using the $record->print_field( $name ); method, you use the $record->print_form_element( $name ) method that prints the form field.

        1. Will definitely try this out. Thank you so much for your time and for this great plugin. we appreciate.

        2. Thank you so much for the help, just got stuck here:

          I was able to use the code above to make a custom display of a record for editing, but I am failing to get the submit button to work. It exists but it does not submit edited data. Kindly advice where am wrong. Here is the code:

          Space Code:print_field('id') ?>
          Item:print_form_element('item') ?>
          Consigneeprint_form_element('consignee') ?>
          Ware House No.print_form_element('wh_entry_no') ?>
          Rate/Dayprint_form_element('rate') ?>
          Invoice Dateprint_form_element('invoice_date') ?>

          SAVE RECORDS

          print_submit_button('button-primary');


          print_form_close() ?>

        3. woa, my code has been stripped: but the submit button code is: $this->print_submit_button('button-primary');

        4. Compare your custom template to the default template. Make sure all the parts are there…especially the $this->print_form_head() function call.

        5. Great!! This has worked-out just fine. Thank you so much!

    2. Hi Philip,

      There are several approaches you could try. One would be to replace the $record->get_edit_link() with code that builds the specific edit link you want for that field.

      First, you’d have your [pdb_record] shortcodes on different pages so that each one edits a different set of fields. You can do this in the shortcode like this: [pdb_record fields="main"]

      Now for each edit link you want to build, you need to construct the link something like this:

      $this->field->link = get_permalink('main-edit') . '?pid=' . $record->get_value('private_id');

      ‘main-edit’ in this example is the name of the page with the [pdb_record fields="main"] shortcode on it. You can do that for as many different group edit pages as you want.

      1. This is so helpful! We’ve been able to implement it on two major groups of fields. Thank you so much Mr. Roland.

        Any ideas concerning the second inquiry above? How we can modify the signup output template to display exactly what we want were we want it e.g. within several columned tables, rather than using loops, etc like it is with the pdb_single template (just as you showed it in a Chrystal clear tutorial –> https://xnau.com/using-the-pdb_template-class-in-your-custom-templates/ Can the same idea be applied to the signup templates? Thank you so much,

        Regards,
        Philip.

  8. Anyway of putting this into a plugin?

  9. […] You may want to combine this with: Adding an Edit Record Link to the Frontend List […]

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.