5

This is more of a theory question than a question with a direct answer.

I've been working with different actions for firing functions when a post is updated or deleted and when users are updated or deleted. For the actions, publish_post and before_delete_post for the posts and personal_options_update, edit_user_profile_update and delete_user for the users.

With post update you get access to the values that are currently set and the values the new values at the same time to make any changes you see fit before anything happens. With user update you only have access to the new information and only after it's already been set.

Is there a reason for this difference or is this just inconsistent?

...and don't get me started on publish_{custom_post_type} vs before_delete_post.

  • 5
    That is the way the various hooks are written. 90% sure that there are no consistent reasons for the decisions. Some make sense, some don't. You really just have to deal with it, sadly. – s_ha_dum Jan 14 '14 at 19:55
  • Where's Andrew Nacin when you need him? – MikeNGarrett Jan 25 '14 at 0:36
  • 2
    Probably on Trac and not on WPSE ;) – kraftner Feb 18 '14 at 10:24
  • 1
    I imagine that you could submit a core patch and get it accepted. A lot of filter/action parameters are what they are because no one has submitted a patch otherwise. – Evan May 3 '14 at 17:23
  • I would second Evan's comment - if someone submits a patch, it opens up a discussion, which is the only way to get a consensus to add parameters. – butlerblog Mar 13 '15 at 4:04
0

It depends on what exact action you are using, and what the purpose of that action is.

For the update actions, for example, there should always be hooks that are triggered before doing the change (so that you may change or prevent it), and hooks that are triggered after the change has been completed (so that you can react to changes).

In your "user" case, if you want to compare the existing vs the changed user, you want to hook into the user_profile_update_errors action. This action gives you an object that shows you what the intended changes are, and whether there's already an existing user. In that case, you can retrieve the existing user through its ID and compare them both.

See: https://codex.wordpress.org/Plugin_API/Action_Reference/user_profile_update_errors

|improve this answer|||||
0

Every system keeps evolving till the end; Same goes for WordPress.

I think reason why post action hooks have evolved much then user related action hooks is because community have been focused on using posts related functionality more then users related stuff.

As we all are aware of the fact that;

A single author publishes multiple posts

Anyways as Evan have mentioned above that "you or someone could submit a core patch for this and get it accepted". Best of Luck with that.

|improve this answer|||||

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.