Overview of Using the MemberPress Developer Tools Addon

This add-on is only included with your purchase of the MemberPress Plus and Pro Editions.

If you're not a developer, you might find our Zapier integration, WP Fusion, or the Uncanny Automator easier to use.

Our MemberPress Developer Tools Add-on extends MemberPress to include a full REST API and full Webhook event capability.

Please note that starting from version 1.2.14, we have removed the password argument for member create and update since it presents a security risk.

If the documentation on this page seems light for developer tools, that's because all the documentation for the webhook events and REST API URLs can be found in the plugin's interface. The interface will actually give you dynamic results to work from and the ability to test webhooks directly from your site. You may also refer to the following additional docs for more info:

Getting started couldn't be easier... here's how

  1. Ensure your MemberPress activation key is for the MemberPress Plus or MemberPress Pro edition.
  2. To install the MemberPress Developer Tools Add-on, go to MemberPress > Add-ons page, and click on the "Install Add-on" button.
  3. To use the MemberPress REST API, you'll need to run WordPress 4.7+
  4. Once the Developer Tools add-on is installed and activated, you should see a new item on your MemberPress menu:
  5. From the Developer Menu, you'll now be able to setup webhooks, view dynamic documentation on and test webhook events and view dynamic documentation on all MemberPress REST API URLs:

Sample PHP cURL Code

This example adds a Member, assigns them to a Membership (via a transaction), and triggers a welcome email in the process:

<?php
$url = 'http://testsite.w6.wpsandbox.pro/wp-json/mp/v1/members';

$ch = curl_init($url);

$data_string = json_encode(
  [
    'email'               => 'testingboy897@test.com',
    'username'            => 'testingboy897@test.com',
    'first_name'          => 'test',
    'last_name'           => 'test_last_name',
    'send_welcome_email'  => true, // Trigger a welcome email - this only works if adding a transaction (below)
    'transaction'         => [
      'membership'  => 376, // ID of the Membership
      'amount'      => '0.00',
      'total'       => '0.00',
      'tax_amount'  => '0.00',
      'tax_rate'    => '0.000',
      'trans_num'   => 'mp-txn-' . uniqid(),
      'status'      => 'complete',
      'gateway'     => 'free',
      'created_at'  => gmdate( 'c' ),
      'expires_at'  => '0000-00-00 00:00:00'
    ]
  ]
);

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data_string );

$header = array();
$header[] = 'MEMBERPRESS-API-KEY: MgCUGSO5Qg'; // Your API KEY from MemberPress Developer Tools Here
$header[] = 'Content-Type: application/json';
$header[] = 'Content-Length: ' . strlen($data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

$response = curl_exec($ch);

if(curl_errno($ch)){
  throw new Exception(curl_error($ch));
}

echo $response;

curl_close($ch);

Webhook Key

Since MemberPress Developer Tools Add-on 1.2.5, we introduced a Webhook Key setting that can be found in the MemberPress menu > Developers > Webhook tab.

You can use the key to authenticate webhook POST requests. It is generated automatically by the MemberPress add-on, but if you feel your key has been compromised, you can regenerate a new webhook key at any time.

To validate the webhook request, fetch HTTP headers and look for memberpress-webhook-key. Here's an example of an HTTP header with memberpress-webhook-key received after creating a new Webhook URL in the MemberPress menu > Developers > Webhook tab and listening to signup events:

Troubleshooting Basic Authentication

The preferred method for authentication is via the API Key provided by MemberPress Developer Tools. However, we know that many of you also use the less secure - Basic Authentication method - to connect to the WP-API. However, this can present a few challenges, which the information below can assist you with.

If you're struggling to get Basic Authentication to work, be sure you've installed the Application Passwords plugin and followed its instructions.

A typical Basic Auth request be as follows:
Header Name: Authorization
Header Value:  Basic base64_encode( wp_admin_user_login_here:application_passwords_password_here )

Your user should have the remove_users capability, or MemberPress Developer Tools will return a 401 response.

If you're still unable to authenticate, then your hosting server may have some configuration issues. Read more about the most common cause here. The Application Passwords plugin must have the PHP_AUTH_USER and PHP_AUTH_PW variables set. If they're not set, Application Passwords will fail to authenticate the user, and you'll need to work with your webhost to correct it. Typically it requires adding something like the following to the .htaccess file:

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

If all else fails, it's best to just use the API Key in the  MEMBERPRESS-API-KEY HTTP request header instead. Below is some sample code with the API Key and PHP cURL:

<?php
$url = 'http://testsite.com/wp-json/mp/v1/me';
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$headers = [ 'MEMBERPRESS-API-KEY: MdCUPSO5Qr', 'Content-Type: application/json' ];
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
$response = curl_exec( $ch );
if( curl_errno( $ch ) ) { throw new Exception( curl_error( $ch ) ); }
curl_close($ch);
echo $response;

Troubleshooting Webhooks

If your test webhooks are working, but your live tests are not firing, then WP Cron is most likely disabled or is not working as it should. MemberPress Developer Tools rely on WP Cron to send out the webhooks.

In this case, the easiest way to verify is to check the wp_mepr_jobs table in your database to see if the webhook jobs are stuck there with a status of "pending".

When possible, we recommend disabling page load based WP Cron and instead triggering it from a server-side cron that runs every minute. SiteGround has a great article on doing this here. And WordPress.org has some additional information here. Unfortunately, we can't assist you with this, and your webhost will need to help you set it up.

If you're unable to get WP Cron firing correctly, even after enabling a server-side cron, then you may (as a last resort) need to issue the following query:

UPDATE wp_options SET option_value = '' WHERE option_name = 'cron';
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.