updated offers expiration hanling with separate checkbox for each 3 offers
This commit is contained in:
@@ -4,7 +4,7 @@ Plugin Name: hggg_cipf
|
|||||||
Plugin URI:
|
Plugin URI:
|
||||||
Description:
|
Description:
|
||||||
Author: hugogogo
|
Author: hugogogo
|
||||||
Version: 0.5.9
|
Version: 0.5.9.3
|
||||||
Author URI:
|
Author URI:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ function send_emails_CIPF($email_name, $user_id = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($emails as $email) {
|
foreach ($emails as $email) {
|
||||||
|
// dont delete, for log
|
||||||
|
error_log("send '".$email_name."' email to: ".$email['to']." (".json_encode($email).")");
|
||||||
|
|
||||||
$sent = wp_mail($email['to'], $email['subject'], $email['message'], $email['headers']);
|
$sent = wp_mail($email['to'], $email['subject'], $email['message'], $email['headers']);
|
||||||
if (!$sent) {
|
if (!$sent) {
|
||||||
error_log('Email sending failed!: ' . json_encode($email));
|
error_log('Email sending failed!: ' . json_encode($email));
|
||||||
@@ -144,6 +147,7 @@ function handle_send_reminders_CIPF($acf_id, $user_id, $date_limit, $reminder_ty
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
set_email_reminder_choice_CIPF($reminder_key, $acf_id);
|
set_email_reminder_choice_CIPF($reminder_key, $acf_id);
|
||||||
|
|
||||||
send_emails_CIPF($email_type, $user_id);
|
send_emails_CIPF($email_type, $user_id);
|
||||||
return; // don't send multiple emails
|
return; // don't send multiple emails
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -109,22 +109,23 @@ add_action('template_redirect', 'partner_form_creation_page_CIPF');
|
|||||||
* actions after partner form is validated
|
* actions after partner form is validated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function partner_after_form_CIPF($form_id, $post_array, $form_type) {
|
//function partner_after_form_CIPF($form_id, $post_array, $form_type) {
|
||||||
Plgntls::debug_infos(2);
|
// Plgntls::debug_infos(2);
|
||||||
$form_partner_id = Cipf::FORM_PARTNER_PAGE_ID;
|
// $form_partner_id = Cipf::FORM_PARTNER_PAGE_ID;
|
||||||
|
//
|
||||||
if ($form_partner_id !== $form_id) {
|
// if ($form_partner_id !== $form_id) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
Plgntls::debug_infos();
|
// Plgntls::debug_infos();
|
||||||
|
//
|
||||||
// error_log("form_id: " . json_encode($form_id));
|
//// error_log("form_id: " . json_encode($form_id));
|
||||||
// error_log("post_array: " . json_encode($post_array));
|
//// error_log("post_array: " . json_encode($post_array));
|
||||||
// error_log("form_type: " . json_encode($form_type));
|
//// error_log("form_type: " . json_encode($form_type));
|
||||||
|
//
|
||||||
$post_id = $post_array['ID'];
|
// // should protect : if post creation there will not be an ID
|
||||||
}
|
// $post_id = $post_array['ID'];
|
||||||
add_action('df_after_process', 'partner_after_form_CIPF', 10, 3);
|
//}
|
||||||
|
//add_action('df_after_process', 'partner_after_form_CIPF', 10, 3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ if (!defined('ABSPATH')) {
|
|||||||
function handle_partner_offers_expire_CIPF($page_id) {
|
function handle_partner_offers_expire_CIPF($page_id) {
|
||||||
Plgntls::debug_infos();
|
Plgntls::debug_infos();
|
||||||
|
|
||||||
|
$post = get_post($page_id);
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($i <= 3) {
|
while ($i <= 3) {
|
||||||
$offer_duration = get_field_init_CIPF('duree_offre_'.$i, $page_id);
|
$offer_duration = get_field_init_CIPF('duree_offre_'.$i, $page_id);
|
||||||
@@ -27,8 +29,12 @@ function handle_partner_offers_expire_CIPF($page_id) {
|
|||||||
++$i;
|
++$i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
handle_offer_is_expired_CIPF($i, $page_id);
|
|
||||||
|
$offer_title = get_field_init_CIPF('offre_'.$i.'_titre', $page_id);
|
||||||
|
error_log("- post: ".$post->post_title." - titre offre: ".$offer_title);
|
||||||
|
|
||||||
handle_offer_will_expire_CIPF($i, $page_id);
|
handle_offer_will_expire_CIPF($i, $page_id);
|
||||||
|
handle_offer_is_expired_CIPF($i, $page_id);
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +54,7 @@ function handle_offer_will_expire_CIPF($i, $page_id) {
|
|||||||
|
|
||||||
$post = get_post($page_id);
|
$post = get_post($page_id);
|
||||||
$user_id = $post->post_author;
|
$user_id = $post->post_author;
|
||||||
handle_send_reminders_CIPF($page_id, $user_id, $date_limit, 'offer_expiration', 'offer_will_expire');
|
handle_send_reminders_CIPF($page_id, $user_id, $date_limit, 'offer_expiration_'.$i, 'offer_will_expire');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +67,9 @@ function handle_offer_is_expired_CIPF($i, $page_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_field('afficher_offre_'.$i, 'Masquer', $page_id);
|
update_field('afficher_offre_'.$i, 'Masquer', $page_id);
|
||||||
set_email_reminder_choice_CIPF('offer_expired', $acf_id);
|
|
||||||
|
$post = get_post($page_id);
|
||||||
|
$user_id = $post->post_author;
|
||||||
send_emails_CIPF('offer_expired', $user_id);
|
send_emails_CIPF('offer_expired', $user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,46 +121,49 @@ function handle_prof_account_deletion_CIPF($user_id) {
|
|||||||
|
|
||||||
send_emails_CIPF('account_deleted', $user_id);
|
send_emails_CIPF('account_deleted', $user_id);
|
||||||
include_once(ABSPATH.'wp-admin/includes/user.php');
|
include_once(ABSPATH.'wp-admin/includes/user.php');
|
||||||
$user = get_user_by('id', $user_id);
|
|
||||||
// dont delete, for log
|
// dont delete, for log
|
||||||
|
$user = get_user_by('id', $user_id);
|
||||||
error_log("delete prof: " . $user->user_login);
|
error_log("delete prof: " . $user->user_login);
|
||||||
|
|
||||||
wp_delete_user($user_id);
|
wp_delete_user($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* it should not be necessary, but just in case
|
* 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) {
|
//function prof_deletion_ensure_images_are_deleted_CIPF($user_id, $reassign, $user) {
|
||||||
Plgntls::debug_infos();
|
// Plgntls::debug_infos();
|
||||||
$role_prof = Cipf::ROLE_PROF;
|
// $role_prof = Cipf::ROLE_PROF;
|
||||||
|
//
|
||||||
if (!in_array($role_prof, $user->roles)) {
|
// if (!in_array($role_prof, $user->roles)) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
$images = get_posts(array(
|
// $images = get_posts(array(
|
||||||
'post_type' => 'attachment',
|
// 'post_type' => 'attachment',
|
||||||
'post_mime_type' => 'image',
|
// 'post_mime_type' => 'image',
|
||||||
'posts_per_page' => -1,
|
// 'posts_per_page' => -1,
|
||||||
'author' => $user_id,
|
// 'author' => $user_id,
|
||||||
));
|
// ));
|
||||||
if (empty($images)) {
|
// if (empty($images)) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
foreach ($images as $image) {
|
// foreach ($images as $image) {
|
||||||
$image_id = $image->ID;
|
// $image_id = $image->ID;
|
||||||
// Set the second argument to true to permanently delete the attachment
|
// // Set the second argument to true to permanently delete the attachment
|
||||||
$result = wp_delete_attachment($image_id, true);
|
// $result = wp_delete_attachment($image_id, true);
|
||||||
if ($result === false) {
|
// if ($result === false) {
|
||||||
error_log('- failed to delete image: ' . $image_id);
|
// error_log('- failed to delete image: ' . $image_id);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
error_log('- delete image: ' . $image_id);
|
// error_log('- delete image: ' . $image_id);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
add_action('deleted_user', 'prof_deletion_ensure_images_are_deleted_CIPF', 10, 3);
|
//add_action('deleted_user', 'prof_deletion_ensure_images_are_deleted_CIPF', 10, 3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
private
2
private
Submodule private updated: 360ed6d219...0b28bb6abc
Submodule wordpress_docker updated: ce6d6b442a...d2fda4af76
Reference in New Issue
Block a user