post_types_to_delete_with_user
Filter HookDescription
Filters the list of post types to delete with a user.Hook Information
| File Location |
wp-admin/includes/user.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 400 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
string[]
|
$post_types_to_delete
|
Array of post types to delete. |
int
|
$id
|
User ID. |
Usage Examples
Basic Usage
<?php
// Hook into post_types_to_delete_with_user
add_filter('post_types_to_delete_with_user', 'my_custom_filter', 10, 2);
function my_custom_filter($post_types_to_delete, $id) {
// Your custom filtering logic here
return $post_types_to_delete;
}
Source Code Context
wp-admin/includes/user.php:400
- How this hook is used in WordPress core
<?php
395 * @since 3.4.0
396 *
397 * @param string[] $post_types_to_delete Array of post types to delete.
398 * @param int $id User ID.
399 */
400 $post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id );
401 $post_types_to_delete = implode( "', '", $post_types_to_delete );
402 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) );
403 if ( $post_ids ) {
404 foreach ( $post_ids as $post_id ) {
405 wp_delete_post( $post_id );
PHP Documentation
<?php
/**
* Filters the list of post types to delete with a user.
*
* @since 3.4.0
*
* @param string[] $post_types_to_delete Array of post types to delete.
* @param int $id User ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-admin/includes/user.php
Related Hooks
Related hooks will be displayed here in future updates.