• Resolved Peter

    (@petert-1)


    I have a fieldmap set up to push new Salesforce Opportunities to a WordPress Custom Post Type. This works and creates a post in draft mode.

    I added the code to automatically publish the post (https://gist.github.com/jonathanstegall/5919e8dcf333336d625f8d87a870dcf5). However when I use this code snippet, it duplicates all the fields that are pushed from Salesforce. They are ACF fields, but I don’t think that matters because it’s pushing to the regular custom field name.

    If I disable the code snippet and manually publish the post, the fields don’t get duplicated.

    Would logging show me what’s happening during the post creation? I’ve enabled it and am waiting for an object to transfer.

Viewing 1 replies (of 1 total)
  • Plugin Author Jonathan Stegall

    (@jonathanstegall)

    When you say you added the code snippet, is it in your theme, or do you have it in an add-on plugin?

    I’m not sure that plugin logging will tell you what is happening, but that is definitely where I would start.

    If it does not tell you what you need to know, I think you should do some logging with that code snippet. For example:

    $params['post_status'] = array(
        'value' => 'publish',
        'method_modify' => 'wp_update_post',
        'method_read' => 'get_post',
    );
    error_log( print_r( $params, true ) );
    return $params;

    This will log, on your server logs, what the params array is doing (it’s a large array) and maybe you can see what the problem is. You may need to change what the code snippet is doing, but doing that log may show you how to change it.

    This plugin doesn’t necessarily support ACF, so it’s possible there’s something weird that it is causing, but there might also be another cause.

Viewing 1 replies (of 1 total)

The topic ‘Auto Publish Post Creates Duplicate Custom Fields’ is closed to new replies.