Apologies, I am not at all familiar with the plugin or the code, this would be a question for MyCred support.
Thread Starter
ibro87
(@ibro87)
Hi vupdraft,
I was told this can be easily achieved with the filter provided. We just need to figure out the function that will clear the cache in the caching plugin. So, I was wondering where can I find this function in your documentation?
This is our code for clearing cache when a post is updated.
public function purge_post_on_update($post_id) {
$post_type = get_post_type($post_id);
$post_type_object = get_post_type_object($post_type);
if ((defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) || ‘revision’ === $post_type || null === $post_type_object || !$post_type_object->public) {
return;
}
You can find all of our caching rules in the Cache >> Class-wpo-cache-rules.php if you download and unpack the plugin
Thread Starter
ibro87
(@ibro87)
Ok. So where should I add MyCred filter (mycred_add_finished) in this function in order to clear the cache when user gain or lose MyCred points?
You would need to do much more than just add the add the filter. You will need to change the code.
For example, you would also need to change the variables (the MyCred version of order_id and items, please see the example below)
The filter is just what you would add to the functions.php to invoke the action
add_action(‘woocommerce_payment_complete’, ‘wpo_flush_wc_purchase’, 10, 1);
function wpo_flush_wc_purchase ( $order_id ) {
$order = new WC_Order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
wpo_cache_flush ( $item[‘product_id’] );
}
I don’t know how the MyCred code or plugin works.
As a workaround you can exclude the pages with the MyCred scores from caching.
Thread Starter
ibro87
(@ibro87)
I’m sorry but I did not find this answer helpful at all. Since MyCred plugin is running on every page, excluding pages from caching definitely isn’t an option. This thread can be closed now.