updated offers expiration hanling with separate checkbox for each 3 offers
This commit is contained in:
@@ -121,46 +121,49 @@ function handle_prof_account_deletion_CIPF($user_id) {
|
||||
|
||||
send_emails_CIPF('account_deleted', $user_id);
|
||||
include_once(ABSPATH.'wp-admin/includes/user.php');
|
||||
$user = get_user_by('id', $user_id);
|
||||
|
||||
// dont delete, for log
|
||||
$user = get_user_by('id', $user_id);
|
||||
error_log("delete prof: " . $user->user_login);
|
||||
|
||||
wp_delete_user($user_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* it should not be necessary, but just in case
|
||||
* ! no sens : it hooks after user is deleted, so images are already added to another user if they are not deleted
|
||||
*
|
||||
*/
|
||||
function prof_deletion_ensure_images_are_deleted_CIPF($user_id, $reassign, $user) {
|
||||
Plgntls::debug_infos();
|
||||
$role_prof = Cipf::ROLE_PROF;
|
||||
|
||||
if (!in_array($role_prof, $user->roles)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$images = get_posts(array(
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => 'image',
|
||||
'posts_per_page' => -1,
|
||||
'author' => $user_id,
|
||||
));
|
||||
if (empty($images)) {
|
||||
return;
|
||||
}
|
||||
foreach ($images as $image) {
|
||||
$image_id = $image->ID;
|
||||
// Set the second argument to true to permanently delete the attachment
|
||||
$result = wp_delete_attachment($image_id, true);
|
||||
if ($result === false) {
|
||||
error_log('- failed to delete image: ' . $image_id);
|
||||
}
|
||||
else {
|
||||
error_log('- delete image: ' . $image_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action('deleted_user', 'prof_deletion_ensure_images_are_deleted_CIPF', 10, 3);
|
||||
//function prof_deletion_ensure_images_are_deleted_CIPF($user_id, $reassign, $user) {
|
||||
// Plgntls::debug_infos();
|
||||
// $role_prof = Cipf::ROLE_PROF;
|
||||
//
|
||||
// if (!in_array($role_prof, $user->roles)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// $images = get_posts(array(
|
||||
// 'post_type' => 'attachment',
|
||||
// 'post_mime_type' => 'image',
|
||||
// 'posts_per_page' => -1,
|
||||
// 'author' => $user_id,
|
||||
// ));
|
||||
// if (empty($images)) {
|
||||
// return;
|
||||
// }
|
||||
// foreach ($images as $image) {
|
||||
// $image_id = $image->ID;
|
||||
// // Set the second argument to true to permanently delete the attachment
|
||||
// $result = wp_delete_attachment($image_id, true);
|
||||
// if ($result === false) {
|
||||
// error_log('- failed to delete image: ' . $image_id);
|
||||
// }
|
||||
// else {
|
||||
// error_log('- delete image: ' . $image_id);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//add_action('deleted_user', 'prof_deletion_ensure_images_are_deleted_CIPF', 10, 3);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user