Using our Javascript Hook API (developers only)

This guide is for the legacy v1 of MemberSpace. For the current v2 API, please visit: https://developers.memberspace.com

We provide the ability for you to access the currently logged in member so that you can further customize your site.

Common use cases include:

  • Displaying certain elements if a member is logged in.
  • Pre-fill forms with a member's information.
  • Displaying personalized messages to members.

How to get started

Start by placing this code on your website:

<script>
  (function() {
    MemberSpace.onReady = MemberSpace.onReady || [];
    MemberSpace.onReady.push(function(args) {
      if (args.member) {
        /* Your custom code goes here */
      }
    });
  }());
</script>

Make sure this code block is below the required MemberSpace Install Code.

The member object data structure will be as follows:

  {
    id: [integer],
    name: [string],
    firstName: [string],
    lastName: [string],
    email: [string],
    profileImageUrl: [string],
    plans: [array],
    plan_ids: [array],
    failedCard: [boolean],
    customField###1: [string],
    customField###2: [string],
    customField###3: [string]
  }

Property Descriptions

id

The member's unique identifier.

name

Simply a string combination of the first and last name of the member.

firstName

A string of the member's first name.

lastName

A string of the member's last name.

email

A string of the member's email address.

profileImageUrl

A url of the member's profile image source.

plans

The plans array is a list of plan names the member is actively subscribed to.

plan_ids

The plan_ids array is a list of plan ids the member is actively subscribed to.

failedCard

The failedCard boolean indicates if the customer currently has a failed payment.

customField

A string of the member's custom sign up fields.

To find the 4 or 5 digit id for each field, go to your MemberSpace account > click on Customize > click Sign Up Fields > then edit the field you're looking for and copy the digits that appear in the URL (/custom_fields/ ####/edit).

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.