• Resolved danatpi

    (@danatpi)


    When syncing new objects over to WordPress a custom post type, is it possible to have them automatically publish instead of created as drafts?

    Thanks,
    Dan

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

    (@jonathanstegall)

    @danatpi yes, there are two ways of doing that.

    1. You can create a Salesforce field called status, give it a value of “publish” and sync it over to the post_status field in WordPress.
    2. You can use a developer hook in a theme or plugin. The relevant hook works like this:

    add_filter( ‘object_sync_for_salesforce_pull_params_modify’,’change_publish_status’, 10, 6 );
    function change_publish_status( $params, $mapping, $object, $sf_sync_trigger, $use_soap, $is_new ) {
    $params[‘post_status’] = array(
    ‘value’ => ‘publish’,
    ‘method_modify’ => ‘wp_update_post’,
    ‘method_read’ => ‘get_post’,
    );
    return $params;
    }

    • This reply was modified 5 years, 5 months ago by Jonathan Stegall. Reason: it might not be in a class
    Thread Starter danatpi

    (@danatpi)

    Awesome, thanks @jonathanstegall for the speedy response! Seems so obvious in retrospect.

    Much appreciated,
    Dan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Default publish status’ is closed to new replies.