Functions available for use in WordPress themes or plugins

Check member permissions

We've included two functions for checking if the current signed in user is subscribed to Plans or owns Downloads. Use them in your WordPress theme template files:

If you pass either of the functions an array of slugs, the function will return true if the member owns any of the Downloads, or is subscribed to at least one of the Plans.

Basic example

Require a subscription to the Big Awesome Plan.

<?php if ( is_subscribed_to_memberful_plan( '154-big-awesome' ) ) : ?>

  Shown only to members with a subscription to the Big Awesome Plan.

<?php endif; ?>

Multiple Plans

Require a subscription to at least one of the listed Plans.

<?php if ( is_subscribed_to_memberful_plan( array( '27-super-rad', '59-rock-on', '99-chill-out' ) ) ) : ?>

  Shown to members with the Super Rad Plan **OR** the Rock On Plan **OR** the Chill Out Plan.

<?php endif; ?>

Plan or Download

Require a subscription to the Big Awesome Plan or require the Super Rad Download.

<?php if ( is_subscribed_to_memberful_plan( '154-big-awesome' ) || has_memberful_download( '27-super-rad' ) ) : ?>

  Shown only to members with a subscription to the Big Awesome plan or the Super Rad download.

<?php endif; ?>

Check against a different member / WordPress user

The two functions check against the current (signed in) member / WordPress user by default. To specify a different member / WordPress user, pass the function an optional WordPress user ID argument.

<?php if ( is_subscribed_to_memberful_plan( array( '27-super-rad', '59-rock-on' ), $user_id ) ) : ?>

  Shown if $user_id is subscribed to the Super Rad or Rock On Plans.

<?php endif; ?>

Add a custom function that checks for any active Plan

Add the following custom function to your functions.php file.

function has_any_memberful_plan() {
  if ( function_exists('memberful_wp_user_plans_subscribed_to') ) {
    $plans = memberful_wp_user_plans_subscribed_to( wp_get_current_user()->ID );
    return !empty( $plans );
  }
  return false;
}

Now has_any_memberful_plan() will return true if the member has access to any Plan.

<?php if has_any_memberful_plan() : ?>

  Shown to members that have any active Plan.

<?php else : ?>

  You need an active Plan to see this content.

<?php endif; ?>

Showing profile information in WordPress themes

We've included a few functions for adding profile information to your theme template files:

Here's an example of using these functions to generate a profile box:

<?php if ( is_user_logged_in() ) : ?>

  <div class="profile-box signed-in">

    <a class="profile" href="<?php echo memberful_account_url(); ?>">

      <?php echo get_avatar( wp_get_current_user()->user_email, 48 ); ?>

      <?php echo wp_get_current_user()->display_name; ?>

    </a>

    <a class="sign-out" href="<?php echo memberful_sign_out_url(); ?>">Sign out</a>

  </div>

<?php else : ?>

  <div class="profile-box signed-out">

    Already a customer? Please <a title="Sign in" href="<?php echo memberful_sign_in_url(); ?>">sign in</a>.

  </div>

<?php endif; ?>

Linking to Downloads

You can use the memberful_account_get_download_url($slug) function to link to a download. The parameter to this function must be the slug of the download you're linking to:

<a href="<?php echo memberful_account_get_download_url( '24-my-download' ); ?>">Download my ebook!</a>

Private RSS Feeds

If you've turned on Private RSS Feeds, you can share a link to the member's private RSS Feed using this function:

<?php memberful_private_rss_feed_link( "Your RSS Feed", "You don't have access." ); ?>

General

How to

CMS Integrations

Email Newsletters

Discussion Forums

WordPress

Video

API