Home › Forums › Bulk Delete Addons › Delete Posts by Custom Field › Delete based on multiple values for custom fields
We have replaced our forums with email based support system.
Please open a support ticket from our new support page.
This topic contains 7 replies, has 2 voices, and was last updated by Sudar 8 years, 4 months ago.
-
AuthorPosts
-
July 5, 2016 at 21:20 #7340
Can the plugin be used to delete multiple posts based on different values of the custom fields?
i.e we have a custom field called ‘package_days_amount’ and if the value is 7 we want it to delete after 7 days, and if the value is 14 we want it to delete the posts after 14 days.
If the plugin requires modification you have any pointers to achieve the above?
Note we have also purchased the scheduler for this 🙂
-
July 6, 2016 at 10:38 #7358
Hello,
Yeah that’s possible.
You just have to create two separate jobs one for each value.
In the first job select the custom field key and value as 7. Also choose the date based on that.
Similarly in the second job choose 14 as the value and also for the days.
Let me know if you still have any more questions regarding this.
-
July 8, 2016 at 22:00 #7384
Hi Sudar,
That did work by the way I was wondering if you could help with some of the complicated php stuff???
I have custom post type called ‘package’
These have a foreach loop setup with the following:
$transaction_package_id = $key->package_id;and inside that we have a custom field called: ‘package_days_amount’ ‘$package_days_amount’
What we are trying to do is pull the value of the above, and put them into another custom post type called ‘events’
into some other custom fields called:
‘package_days_amount’ ‘$package_days_amount’This is the complicated stuff that i’m struggling with but you might find easy :/ ???
-
July 8, 2016 at 22:15 #7385
This is what I’ve tried inside the foreach loop:
$package_days_amount_event = get_post_meta($td_slot_id, ‘package_days_amount’, true);
if ( $package_days_amount == ‘1’ ) {
update_post_meta( $post_id, ‘package_days_amount_event’, ‘1’ );
}
if ( $package_days_amount == ‘7’ ) {
update_post_meta( $post_id, ‘package_days_amount_event’, ‘7’ );
}
if ( $package_days_amount == ’14’ ) {
update_post_meta( $post_id, ‘package_days_amount_event’, ’14’ );
}
if ( $package_days_amount == ’30’ ) {
update_post_meta( $post_id, ‘package_days_amount_event’, ’30’ );
}
if ( $package_days_amount == ‘forever’ ) {
update_post_meta( $post_id, ‘package_days_amount_event’, ‘forever’ );
}
else {
//do nothing
} -
July 8, 2016 at 22:16 #7386
Note my code above didn’t work
-
July 10, 2016 at 21:46 #7392
What is the error you are getting?
Also can you post the full code in gist and then post the link here?
-
July 11, 2016 at 15:12 #7398
Hi here’s the link to the code
https://github.com/colingell/bulkdelete
It has two files: eventuploadform.php – this is the one where I don’t seem to be able to pull the $package_days_amount field from the ‘package’ post type, and save it as ‘$package_days_amount_event’
The second file is the one that generates the $package_days_amount field it also allows me to manually update the $package_days_amount_event field from the backend of wordpress, and in this regard it works perfectly.
I don’t have any error records showing for either of the above files, it’s just that eventuploadform.php doesn’t seem to update the sql database with the $package_days_amount_event field
-
July 13, 2016 at 09:14 #7446
Sorry, I am not able to figure out why it is not working. I would need access to your server, DB etc to debug it further since I don’t see any obvious issues.
You may have to hire someone to fix it for you.
-
AuthorPosts
The forum ‘Delete Posts by Custom Field’ is closed to new topics and replies.