Site-to-Site-Link
To authenticate with D.T from another server.
Creating the token
Go to the wp-admin. Open Site Links in the menu on the left. Click the Add New button.
In Site 1 add the D.T domain. Example: example.disciple.tools
In Site 2 add the remote server's. Example: example.com
note: both domains need to be HTTPS. You can disable this for local testing by enabling WP_DEBUG
Connection type: You will create a connection type and associate permissions to it. See below.
Since you are not connecting to another D.T instance, under DT Site choose 'No, connection for a non-Disciple Tools system.'.
See more documentation on creating a site link here
Remote authentication
We'll use the token and the 2 domains we just defined to authenticate with D.T form another server.
Here are example for creating a contact. Note we are not using the endpoints that include "dt_public" in the url. Those most likely will not work.
PHP Example
function create_contact( $fields ) {
$token = "token from the Site to Site link";
$site_key = md5($token . "example.disciple.tools" . "example.com");
$transfer_token = md5($site_key . date('Y-m-dH'));
$url = 'https://example.disciple.tools/wp-json/dt-posts/v2/contacts';
$req = curl_init();
curl_setopt_array($req, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($fields),
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"cache-control: no-cache",
"Authorization: Bearer " . $transfer_token
),
));
$response = curl_exec($req);
return json_decode($response);
}Wordpress Example
Node example
Connection Types
Here is how you add a connection type and the right permissions from you D.T plugin.
For a list of permissions see Permissions. In the site_link_capabilities function you can add your own permission that you use later on in your plugin.
Last updated
Was this helpful?