[wp-trac] [WordPress Trac] #61448: Add a 'pre_delete_user' filter to allows some checks to potentially prevent user deletion

WordPress Trac noreply at wordpress.org
Fri Jun 14 20:29:30 UTC 2024


#61448: Add a 'pre_delete_user' filter to allows some checks to potentially prevent
user deletion
-------------------------+-----------------------------
 Reporter:  axi35        |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Users        |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 **Context**:
 I'm developping a complex website based on woocommerce + wc booking, where
 the owner of products are not the admin but some users (hosts). There's
 some moment where a user (host, clien) MUST not be deleted, for example if
 a booking is planned & paid but not done yet.
 I need to prevent user from being delete by themselves (unsubscribe
 action, easy to act on) but also if an admin try to in wp-admin (no nice &
 easy way to do it).

 Currently, I use the `'delete_user'` action and throw a `wp_die()` when my
 checks says the deletion is not allowed but it's not ideal.

 **Proposition**:
 Adding a a new `'pre_delete_user'` filter would allow to act more nicely
 on this low-level action.
 There's already some `'pre_delete_X'` hooks existing, like
 `'pre_delete_post'`, `'pre_delete_attachment'` and woocommerce use it for
 all its types `'woocommerce_pre_delete_OBJECT_TYPE'` so it looks like a
 good way to handle those checks.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61448>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list