delete all post and attachments of a user delete codegrapper
add_action('delete_user', 'my_delete_user');
function my_delete_user($user_id) {
$args = array (
'numberposts' => -1,
'post_type' => 'any',
'author' => $user_id
);
// get all posts by this user: posts, pages, attachments, etc..
$user_posts = get_posts($args);
if (empty($user_posts)) return;
// delete all the user posts
foreach ($user_posts as $user_post) {
wp_delete_post($user_post->ID, true);
}
}
Also in PHP:
- change url header php
- echo errors of php
- clear database cache laravel command
- carbon laravel use
- automatically refresh a php code
- check sizee string laravel
- clear composer cache
- add more data to variable php
- Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://D:/Program Files/Composer - PHP/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223
- drop column migration laravel
- Customer::insert([ 'customer_name' => $request->customer name, 'customer mobile'=> $request->customer mobile, 'user_id'=>Auth::user()->id, 'created_at'=> Carbon::now() ]);
- delete in wordpress query
- add new column in existing table in laravel migration
- dateFormat php
- Artisan namespace
- dates phpp
- date / time formatter php
- Modularizing laravel 8.0
- console.log equivalent in php
- How to handle max time of execution
- exceptions php
- detecting right click on windows
- destroy session php
- array reverser ph