Title: &quot;Last edited by&quot; capability
Last modified: August 21, 2016

---

# "Last edited by" capability

 *  Resolved [Billmel](https://wordpress.org/support/users/billmel/)
 * (@billmel)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/last-edited-by-capability/)
 * I just finished reading your description of how to capture information about 
   WordPress users in a record. What I would like to do is to capture the WordPress
   username of the person who last edited a record, not just the person who originally
   created it. Is that possible? I’m also interested in capturing when the record
   might have been edited by someone who is not logged in.
 * Thanks!
 * [https://wordpress.org/plugins/participants-database/](https://wordpress.org/plugins/participants-database/)

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686015)
 * This is not too hard to do on the frontend, a little more difficult in the backend.
   Both will require some knowledge of PHP. What I’m going to explain won’t make
   much sense unless you’re a bit of a WordPress coder. There’s is really no other
   way to do it, and if it’s not something you know how to do, you may want to contact
   a developer to get his done for you.
 * You’d need to [create a custom template](http://xnau.com/work-2/wordpress-plugins/participants-database/pdb-templates/)
   for your record shortcode, and have a field set up that grabs the user name or
   id of the currently logged in user. (details on that [here](http://xnau.com/using-participants-database-with-wordpress-users/))
   The way this works is it only records the value if it’s empty (i.e. for the first
   time) if you want it to record this value every time, you need to clear it’s 
   value in the record object before the form head is printed in the template.
 * If you need to do this on the backend you’ll need to attach a handler to the ‘
   pdb-before_submit_update’ filter to update the value before it’s saved. You can
   do this in your functions.php file or in an auxiliary plugin.
 * Your last request will need something again attached to the ‘pdb-before_submit_update’
   filter. I don’t know what you want to do when someone edits a record while not
   logged in. but you’ll be able to tell when that filter is executed so you can
   do whatever you want done if that happens. Put your record shortcode on a protected
   page (logged-in users only) and you won’t have to worry about it, if that’s the
   issue.
 *  Thread Starter [Billmel](https://wordpress.org/support/users/billmel/)
 * (@billmel)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686031)
 * That should be enough of a hint to get started; Thanks!
 *  Thread Starter [Billmel](https://wordpress.org/support/users/billmel/)
 * (@billmel)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686052)
 * First of all, I only need to do this in the front end, so hopefully that makes
   it easier.
 * If I insert the code to update the ‘edited_by’ field as you suggest in the while
   $this->have_fields() loop, it will update the field anytime someone displays 
   the pdb_record form; what I would like to do is do the update only when a change
   is made to the form.
 * Thanks!
 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686077)
 * The ‘pdb-before_submit_update’ filter is only used when someone updates the record,
   not just when it’s displayed, so it will work like you want.
 *  [YaniMosi](https://wordpress.org/support/users/yanimosi/)
 * (@yanimosi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686254)
 * Hi,
    I am trying to use the pdb-before_submit_update filter but I could not get
   the result as expected. In my funtions.php I got: add_filter(‘pdb-before_submit_update’,’
   format_my_fields’), and I create the function format_my_fields to change entered
   fields as would like to get it in different format. After submitting the form
   it show the change made from the function, but when leave the form, data still
   as entered not as formatted. What is the best way to get it work? I am using 
   $_POST[]; inside the function. Thanks!!
 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686255)
 * You are supposed to return the modified array, not directly manipulate the $_POST
   array.
 *  [YaniMosi](https://wordpress.org/support/users/yanimosi/)
 * (@yanimosi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686256)
 * Thanks for your answer,
 * I had a look to understand what is going out then I notice that, when
    the pdb-
   before_submit_update is added and submit alteration, the record is not updated,
   whatever $_POST[] is there or not. I commented the $_POST[] and still the same.
   Wher in Case-2, record is updated.
 * **CASE-1: **
    _Record is not updated. But, no action is taken inside of the function.
   function format\_my\_fields(){ // exemple //$\_POST[‘city’] = $city. “my change
   etc…”; //return $\_POST[‘city’]; } add\_filter(‘pdb-before\_submit\_update’,’
   format\_my\_fields’); ?>
 * **CASE-2: **
    _Record updated. (No presence of the filter)_
 * function format_my_fields(){
    // exemple //$_POST[‘city’] = $city. “my change
   etc…”; //return $_POST[‘city’]; } //add_filter(‘pdb-before_submit_update’,’format_my_fields’);?
   >
 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686257)
 * I’m sorry, I don’t provide support for the use of the API. I’m willing to answer
   simple questions, but you’re going to have to figure this out yourself. These
   features are for experienced programmers, and if it’s beyond your ability, you
   can consider it an opportunity to learn more.
 * If you look carefully at the answer I gave before, you’ll see your problem.
 *  [YaniMosi](https://wordpress.org/support/users/yanimosi/)
 * (@yanimosi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686258)
 * I understand that, I was figuring out if is a bag or not. The fact is reading
   your description, just adding the The ‘pdb-before_submit_update’ filter in the
   function.php, the plugin will not update any field, not only the changed field
   but all of them, I think is a simple fact. But, fine… Will find other way!
    Thanks!
 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686259)
 * It works, you’re not doing it right. The filter callback gets an array, you modify
   that array then return the modified array. Don’t do anything to the $_POST array.
 *  Thread Starter [Billmel](https://wordpress.org/support/users/billmel/)
 * (@billmel)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686260)
 * Can I suggest that you provide the basics for what what sort of call back function
   needs to be provided to the add_filter(), and what parameters will be passed 
   to it at callback? I suspect a very simple example could be easily constructed
   with this, and if that example showed the appropriate return(), it might make
   this interface more obvious to someone who isn’t a WordPress hacker.
 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686261)
 * It’s not unlike most WordPress filter callbacks, the function is given an array
   of values, and you are expected to return that array of values. You can alter
   it or not.
 * For a trivial example, let’s say you want to make sure the name is capitalized…
 *     ```
       <?php
       add_action('pdb-before_submit_update', 'capitalize_name');
       function capitalize_name($post) {
          if (isset($post['first_name']) {
             $post['first_name'] = ucwords($post['first_name']);
          }
          return $post;
       }
       ?>
       ```
   
 *  Thread Starter [Billmel](https://wordpress.org/support/users/billmel/)
 * (@billmel)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686263)
 * That’s really helpful, at least for me.
 * FYI: I think you meant to write “if (isset($post[‘first_name’])) {”
 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686265)
 * yeah, good catch!
 *  [YaniMosi](https://wordpress.org/support/users/yanimosi/)
 * (@yanimosi)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686266)
 * Thanks, helpful for any one looking to use the plugin more deeper.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘"Last edited by" capability’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

 * 15 replies
 * 3 participants
 * Last reply from: [YaniMosi](https://wordpress.org/support/users/yanimosi/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/last-edited-by-capability/#post-4686266)
 * Status: resolved