Support » Plugin: WPSiteSync for Content » Unset some data from being sync

  • Resolved shgotlib

    (@shgotlib)


    I want to unset some data from the synced data.
    I found the filter spectrom_sync_api_push_content and I did somthing like this:

    function shlomi_test_wpsc($data) {
    	$post_id = $data['post_id'];
    	if (isset($data['thumbnail'])) {
    	    $data['thumbnail'] = '';
    	}
    	if(isset($data['post_meta']['_thumbnail_id'])) {
    	    unset($data['post_meta']['_thumbnail_id']);
    	}
    
    	unset($data['post_data']['post_content']);
    
    	unset($data['post_meta']['important']);
    }
    add_filter('spectrom_sync_api_push_content', 'shlomi_test_wpsc', 2);
    

    So, ['post_meta']['important'] is did not sync as I expected, and this is great, but the post content is removed form the target site, and the post thumbnail is still persist to be sync.

    Thanks for your help,
    Shlomi

    • This topic was modified 1 year, 8 months ago by  shgotlib.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Anyone can help please?

    Plugin Author ServerPress

    (@serverpress)

    Hi shgotlib,

    So sorry, we didn’t see this question until now.

    The ‘spectrom_sync_api_push_content’ is a filter, so you need to return the $data variable at the end of your callback function.

    Try that and let us know how that works for you.

    Hi, Thanks for your answer.
    I do have a return statement in the end of the function.

    The data is syncing properly based on my custom filter, but I have a problem only in the post content and the thumbnail.

    In the content, if I exclude it from the sync, it’s remove the target post content completely.
    In the featured image, if I ask from the filter to unset it, it’s still persist to sync it.

    Maybe it’s an issue with your apply_filter itself?

    Thanks

    So, what about it?
    If you can’t support on operation like this please just let me know please.
    Right now, excluding from sync the featured image or main content is impossible.

    Thanks

    Plugin Author ServerPress

    (@serverpress)

    Hi shgotlib,

    I think I’m seeing the problem. Removing the post content and thumbnail information from the API data is telling WPSiteSync that this information does not exist. When the data does not exist, WPSiteSync removes it on the Target site. I think what you’re looking for is to not update the information on the Target, as opposed to removing the information. Is that correct? Also, the featured image itself is handled separately- in a different API call. So the image will still be Pushed, regardless of the value of the thumbnail id associated with the post.

    We would like to ask you to submit a support request through our normal support channel at https://serverpress.com/contact/ – this will allow us to better resolve this issue since we work the support items daily and we don’t do that here on the WordPress forums.

    Please include all of the code that you’re working with so we can get an idea of what you are doing, as well as a description of what you would like the results to be. We do think that we can make this work but it might require some small changes to how the API data is being handled in the core WPSiteSync product. Having the code will help us in determining the best solution for your desired result.

    Many thanks.

    I sent, thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Unset some data from being sync’ is closed to new replies.