Javascript Hook (developers only)


Javascript Hook (front end API) Instructions

Warning: This guide is for people comfortable with Javascript programming.

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, and displaying personalized messages.

To use the javascript hook 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 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],
    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.

failedCard

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

customField

A string of the member's custom field. To find the 4 or 5 digit id for each field, go to Customize >  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.

Still need help? Contact Us Contact Us