• Resolved katjavolker

    (@katjavolker)


    Hi, I really need som more information on how to do what.
    I have added a field with a key ‘xxx’. How do I determine the methods for this field? Where do they come from?

    The field is showing up in the list but I have no idea what it does and how. How do I test that before syncing? Can I var_dump the data somehow?

    Also object data hook field I created shows up in the list of fields even though I specifically asked for object_type product.

    What I need to accomplish is to map the term name/ID of the product.

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

    (@jonathanstegall)

    I don’t provide a lot of support for the developer hooks here, but I’ll try to give some basic guidance.

    It sounds like you’re using the object_sync_for_salesforce_wordpress_object_fields filter. If not, you need to be more specific, but I’ll start with that assumption.

    This hook is meant to allow you to add fields that aren’t added in a standard WordPress way. So if you were working with the user object, this would mean user fields that are not in wp_users or wp_usermeta. The methods array means that there needs to be a WordPress function that can work similarly to the core WP methods.

    From the docs:

    
    array (
        'key' => 'ID',
        'table' => 'wp_users',
        'methods' => array (
            'create' => 'wp_insert_user',
            'read' => 'get_user_by',
            'update' => 'wp_update_user',
            'delete' => 'wp_delete_user'
        )
    ),
    

    In this example, you can see the methods for a standard WordPress user ID field. You can create it with wp_insert_user, read it with get_user_by, update it with wp_update_user, and delete with wp_delete_user.

    What this means is that your field needs to have equivalent methods for creating, reading, updating, and deleting its value.

    And yes, you certainly can do a var_dump or error_log of any parameters that you want in this filter. It’s always a good idea.

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    I’m going to mark this as resolved, as it doesn’t seem like you need further help and it is about the specific functionality of developer hooks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘object fields hook, object data hook’ is closed to new replies.