• Resolved ilana Bittner

    (@ilanabit)


    I have a site set up to sync Salesforce Contacts with WordPress Users. My client has a field in Salesforce that she wants to sync to WordPress that is a single checkbox, labeled “Do Not Contact”. So far as I can tell, WordPress doesn’t allow for such a field, there needs to be at least a binary (y/n) choice.

    Before I dig around any longer for solutions, I wanted to check and make sure the plugin can handle that kind of a filed.

    Also, if you have any ideas, I’d grateful for other opinions.

    Thanks!

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

    (@jonathanstegall)

    @ilanabit hm, sure. We have similar things in our setup. The way I’ve done it is with the CMB2 plugin, which does have checkbox fields built into it. For example we have a Contact with a checkbox field for sustaining member status. We create a checkbox in CMB2 with that field type, and then we add it to the fieldmap and only sync it from Salesforce to WordPress. This way only Salesforce is able to update that field’s value (but other checkboxes will sometimes sync both ways).

    It’s relatively standard CMB2 code, I guess. Here’s the relevant part:

    $user_donation_info = new_cmb2_box(
    array(
    ‘id’ => ‘user_donation_info’,
    ‘title’ => __( ‘Donation Info’, ‘minnpost-largo’ ),
    ‘object_types’ => array( $object_type ),
    ‘context’ => ‘normal’,
    ‘priority’ => ‘low’,
    )
    );

    $user_donation_info->add_field(
    array(
    ‘name’ => __( ‘Sustaining Member’, ‘minnpost-largo’ ),
    ‘id’ => ‘_sustaining_member’,
    ‘type’ => ‘checkbox’,
    ‘desc’ => ”,
    )
    );

    Does that help send you in the right direction?

    Thread Starter ilana Bittner

    (@ilanabit)

    Yes! Thank you. I haven’t used CMB2 before, and have been looking for a good reason to check it out!

    In this case, the WP use is a Member Directory so I used BuddyPress to create additional fields, but it looks like CMB2 just punches a new field directly into the User.

    That’s awesome, now I have something new to explore Monday morning!

    Thanks so much, Jonathan. Have a great weekend.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Salesforce Checkbox Field’ is closed to new replies.