Below is a list of WordPress Custom Action Hooks we have integrated into WP Contacts and example implementations of these hooks. These hooks are used to send information to other Applications from WP Contacts when an event occurs.
Table of Contents
Open Table of Contents
Entry Creation
Action Hook: wcp_add_entry_action
<?php
add_action('wcp_add_entry_action', array($this, 'add_entry_hook'), 10, 2);
/**
* Add Entry Action
*/
public function add_entry_hook($fields, $environment) {
$url = "https://yoursite.com";
$action = 'add_entry';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'fields' => $fields,
'environment' => $environment,
)
)
);
}
Entry Updated
Action Hook: wcp_update_entry_action
<?php
add_action('wcp_update_entry_action', array($this, 'update_entry_hook'), 10, 2);
/**
* Update Entry Action
*/
public function update_entry_hook($fields, $environment) {
$url = "https://yoursite.com";
$action = 'update_entry';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'fields' => $fields,
'environment' => $environment,
)
)
);
}
Entry Removed
Action Hook: wcp_del_entry_action
<?php
add_action('wcp_del_entry_action', array($this, 'del_entry_hook'), 10, 2);
/**
* Delete Entry Action
*/
public function del_entry_hook($fields, $environment) {
$url = "https://yoursite.com";
$action = 'delete_entry';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'fields' => $fields,
'environment' => $environment,
)
)
);
}
Entry Note Created
Action Hook: wcp_addnote_entry_action
<?php
add_action('wcp_addnote_entry_action', array($this, 'addnote_entry_hook'), 10, 4);
/**
* Add Entry Note Action
*/
public function addnote_entry_hook($entry_id, $note, $note_id, $environment) {
$url = "https://yoursite.com";
$action = 'add_note';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'entry_id' => $entry_id,
'note' => $note,
'note_id' => $note_id,
'environment' => $environment,
)
)
);
}
Entry Note Updated
Action Hook: wcp_updatenote_entry_action
<?php
add_action('wcp_updatenote_entry_action', array($this, 'updatenote_entry_hook'), 10, 4);
/**
* Update Entry Note Action
*/
public function updatenote_entry_hook($entry_id, $note, $note_id, $environment) {
$url = "https://yoursite.com";
$action = 'update_note';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'entry_id' => $entry_id,
'note' => $note,
'note_id' => $note_id,
'environment' => $environment,
)
)
);
}
Entry Note Removed
Action Hook: wcp_delnote_entry_action
<?php
add_action('wcp_delnote_entry_action', array($this, 'delnote_entry_hook'), 10, 4);
/**
* Delete Entry Note Action
*/
public function delnote_entry_hook($entry_id, $note, $note_id, $environment) {
$url = "https://yoursite.com";
$action = 'delete_note';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'entry_id' => $entry_id,
'note' => $note,
'note_id' => $note_id,
'environment' => $environment,
)
)
);
}
Entry Photo Changed
Action Hook: wcp_photo_entry_action
<?php
add_action('wcp_photo_entry_action', array($this, 'photo_entry_hook'), 10, 3);
/**
* Entry Photo Action
*/
public function photo_entry_hook($entry_id, $new_file_url, $environment) {
$url = "https://yoursite.com";
$action = 'add_photo_entry';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'entry_id' => $entry_id,
'new_file_url' => $new_file_url,
'environment' => $environment,
)
)
);
}
Entry File Added
Action Hook: wcp_addfiles_entry_action
<?php
add_action('wcp_addfiles_entry_action', array($this, 'addfiles_entry_hook'), 10, 3);
/**
* Add Entry Files Action
*/
public function addfiles_entry_hook($entry_id, $file_data, $environment) {
$url = "https://yoursite.com";
$action = 'add_files_entry';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'entry_id' => $entry_id,
'file_data' => $file_data,
'environment' => $environment,
)
)
);
}
Entry File Removed
Action Hook: wcp_delfiles_entry_action
<?php
add_action('wcp_delfiles_entry_action', array($this, 'delfiles_entry_hook'), 10, 3);
/**
* Delete Entry Files Action
*/
public function delfiles_entry_hook($entry_id, $file_data, $environment) {
$url = "https://yoursite.com";
$action = 'delete_files_entry';
$response = wp_remote_post($url,
array(
'method' => 'POST',
'body' => array(
'action' => $action,
'entry_id' => $entry_id,
'file_data' => $file_data,
'environment' => $environment,
)
)
);
}