0
votes

I need to trigger a "publish_post" action for a custom post type. I defined a trigger named "publish_book" under "hook press_action".

$hookpress_actions = array('publish_book'=>array('BOOK'),'add_attachment'=>array('ATTACHMENT'),
........
);

After that I defined the field names I need to pass in "hookpress_get_fields" function as follows.

if ($type == 'BOOK') $fields  = array('post_url','post_type');

I can see the action and the fields listed in the web hook settings page. It even triggers when a new book post is published. However, the post_type, post_title fields values are not sent in the request. How can I capture the values of those fields and pass them to the web hook URL ?

1

1 Answers

0
votes

After going through the plugin code I noticed that we need to explicitly add the fields to the request. We need to add following changes to the "hookpress_generic_action" function (defined in Include.php file) which is called during a publish event.

foreach($args as $i => $arg) {
    $newobj = array();
    switch($arg_names[$i]) {
        case 'BOOK':
            $newobj = get_post($arg,ARRAY_A);
            break;
        default:
            $newobj[$arg_names[$i]] = $arg;
      }
}