0

I have created a role where a person can make changes to a users profile.

I'm afraid that, at one point in time, there will be a discussion between a moderator and a user about the changes of a profile. If the user doesn't agree with the changes and asks the moderator why he did it, the reaction of the moderator can be that he didn't change the profile.

To prevent this discussion I would like to have a "user log" that monitors all the activity on a users profile.

I have searched the internet but with no luck. Maybe it's just my way of searching that wasn't good. I prefer to do this without a plugin but if there is no other way I would do it with one.

Can anyone recommend a way to do it or at least some keyword to search by?

M.

2

You can use edit_user_profile_update hook.

This action hook is generally used to save custom fields that have been added to the WordPress profile page.

add_action( 'edit_user_profile_update', 'update_extra_profile_fields' );

function update_extra_profile_fields( $user_id ) {
    if ( current_user_can( 'edit_user', $user_id ) ) {
        update_user_meta( $user_id, 'my_custom_field', $_POST['your_field'] );
    }
}

With update_user_meta you can check the response of each custom field while saving that is it new or same as before.

Meta ID if the key didn't exist; true on successful update; false on failure or if $meta_value is the same as the existing meta value in the database.

You can crate a new table for log or use posts table with new post type user_log and display entries in back-end.

You can also try the WP Security Audit Log plugin.

  • Yes but then I would only know if a field is changed. I would like to know who changed the field! I have seen the WP Security Autit Log plugin. I'll take a look at it. Thnx! – Interactive Sep 14 '15 at 13:40
  • You can get the loogedin user id and info form get_currentuserinfo(); – avinashphp Sep 14 '15 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.