This code exposes CiviCRM's extern scripts as WordPress REST endpoints.
- PHP 7.3+
- WordPress 4.7+
- CiviCRM to be installed and activated.
-
civicrm/v3/rest
- a wrapper aroundcivicrm_api3()
Parameters:
key
- required, the site keyapi_key
- required, the contact api keyentity
- required, the API entityaction
- required, the API actionjson
- optional, json formatted string with the API parameters/argumets, or1
as injson=1
By default all calls to
civicrm/v3/rest
return XML formatted results, to getjson
formatted result passjson=1
or a json formatted string with the API parameters, like in the example 2 below.Examples:
-
https://example.com/wp-json/civicrm/v3/rest?entity=Contact&action=get&key=<site_key>&api_key=<api_key>&group=Administrators
-
https://example.com/wp-json/civicrm/v3/rest?entity=Contact&action=get&key=<site_key>&api_key=<api_key>&json={"group": "Administrators"}
-
civicrm/v3/url
- a substition forcivicrm/extern/url.php
mailing tracking -
civicrm/v3/open
- a substition forcivicrm/extern/open.php
mailing tracking -
civicrm/v3/authorizeIPN
- a substition forcivicrm/extern/authorizeIPN.php
(for testing Authorize.net as per docs)Note: this endpoint has not been tested
-
civicrm/v3/ipn
- a substition forcivicrm/extern/ipn.php
(for PayPal Standard and Pro live transactions)Note: this endpoint has not been tested
-
civicrm/v3/cxn
- a substition forcivicrm/extern/cxn.php
-
civicrm/v3/pxIPN
- a substition forcivicrm/extern/pxIPN.php
Note: this endpoint has not been tested
-
civicrm/v3/widget
- a substition forcivicrm/extern/widget.php
Note: this endpoint has not been tested
Set the CIVICRM_WP_REST_REPLACE_MAILING_TRACKING
constant to true
to replace mailing url and open tracking calls with their counterpart REST endpoints, civicrm/v3/url
and civicrm/v3/open
.
Note: use this setting with caution, it may affect performance on large mailings, see CiviCRM_WP_REST\Civi\Mailing_Hooks
class.