• Resolved ibanezrg770

    (@ibanezrg770)


    Hi, first I am completely new to WordPress programming so please forgive me…

    I have created a custom table named wp_sf_groups with 3 fields:
    id
    sf_id
    sf_name

    I have inserted the object type code and the table properly shows in the WordPress Object dropdown. However, when I try to select the field, the Worpress dropdown only displays:
    undefined
    undefined
    undefined

    I am not quite sure where to insert the hook and whether I need to define the fields themselves. I imagine it is looking at the table as it is returning 3 fields. It is also replacing all my dropdowns for any object type with the same 3 undefined fields.

    Here is the code I added as well as the default code above and below it to show placement in the file. Any advice would be extremely helpful.

    /*
    * Developers can use this hook to change the WordPress object field array.
    * The returned $object_fields needs to be an array like is described earlier in this method:
    * $object_fields = array( ‘data’ => array(), ‘from_cache’ => bool, ‘cached’ => bool );
    * This is useful for custom objects that do not use the normal metadata table structure.
    */
    add_filter( ‘object_sync_for_salesforce_wordpress_object_fields’, ‘add_field’, 10, 2 );
    $object_fields[‘data’][] = array(
    ‘key’ => ‘id’,
    ‘table’ => ‘sf_groups’,
    ‘methods’ => array (
    ‘create’ => ‘sf_groups_plugin_create’,
    ‘read’ => ‘sf_groups_plugin_read’,
    ‘update’ => ‘sf_groups_plugin_update’,
    ‘delete’ => ‘sf_groups_plugin_delete’
    )
    );
    return $object_fields;

    $object_fields = apply_filters( $this->option_prefix . ‘wordpress_object_fields’, $object_fields, $wordpress_object );

    return $object_fields[‘data’];

    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ibanezrg770

    (@ibanezrg770)

    I believe I figured the part to insert the correct fields but now I get an undefined function error when the sync is triggered.

    2020-03-19 21:34:27 +0000
    unexpected shutdown: PHP Fatal error Uncaught Error: Call to undefined function sf_groups_id_plugin_create() in /var/www/wordpress/wp-content/plugins/object-sync-for-salesforce/classes/wordpress.php:2523 Stack trace: #0

    Here is my code if you could help:

    add_filter( ‘object_sync_for_salesforce_wordpress_object_fields’, ‘add_field’, 10, 2 );
    function add_field( $object_fields, $wordpress_object ) {
    $object_fields[‘data’][] = array(
    ‘key’ => ‘id’,
    ‘table’ => ‘wp_sf_groups’,
    ‘methods’ => array (
    ‘create’ => ‘sf_groups_id_plugin_create’,
    ‘read’ => ‘sf_groups_id_plugin_read’,
    ‘update’ => ‘sf_groups_id_plugin_update’,
    ‘delete’ => ‘sf_groups_id_plugin_delete’
    )
    );
    $object_fields[‘data’][] = array(
    ‘key’ => ‘sf_group_name’,
    ‘table’ => ‘wp_sf_groups’,
    ‘methods’ => array (
    ‘create’ => ‘sf_groups_plugin_create’,
    ‘read’ => ‘sf_groups_plugin_read’,
    ‘update’ => ‘sf_groups_plugin_update’,
    ‘delete’ => ‘sf_groups_plugin_delete’
    )
    );

    return $object_fields;
    }

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    What this seems to mean is that you are asking the plugin to call a function called “sf_groups_plugin_create” but that it doesn’t exist. If you’re sure the function does exist, it’s possible that you’ll need to change the value on add_filter( ‘object_sync_for_salesforce_wordpress_object_fields’, ‘add_field’, 10, 2 ); from 10 to a higher number. The 10 is a priority default, but if you increase it, it will run later in the process. See more in the WordPress docs.

    In any case, there’s a lot of documentation on the developer hooks, but the kind of support we can provide for them in this forum is pretty limited.

    Hey @ibanezrg770 were you able to solve this? Interested in your topic

    • This reply was modified 4 years, 7 months ago by gijungkim.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fields in custom table come back as undefined’ is closed to new replies.