Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
news-topic
User Story: Keeping The Brooklyn Triathlon Club Connected
Avatar
Simple Press
Admin
sp_UserOfflineSmall Offline
Jun 13, 2019 - 1:55 pm
sp_QuotePost Quote


This article is the third in a series of “user stories” where our users describe how they built their sites using Simple:Press. In this story you will learn how Vicky Wei built out a WordPress membership site using Simple:Press and the WishList Member plugin.

Introduction


The Brooklyn Triathlon Club
has been around since 2004 and our website in action since 2010. We are based
in Brooklyn, NY and the forum is used for all communications to and among the
club organizers, coaches, and members. This includes social events, workshops,
sponsor discounts to our members, and coached training details. It’s a huge
resource for our members to communicate with each other to organize training,
socializing, providing tips and discussion via the forum.


We are tight-knit community that has around 200 - 300 members in a given year. Access to our forum is by an annual calendar fee, which also gives members access to our coached training, social events, and workshops.


We use another Wordpress plugin, WishList Member to manage active membership and payments.


In addition to the forum website being limited to active members, key functionalities required are email notifications for posts and the ability to reply by email. These are turned on and off based on a members active or expired status in WishList Member.

Problem Scope


In building out the site, we encountered a number of challenges that were unique to our vision of how the site should operate.


For example: Members become active when they pay the annual calendar year fee. This can occur on any day of the year. The issue we needed to solve came in two parts; (1) restricting access to the forum based on a members status as an active or non-active user in WishList Members, and (2) restricting access to the forum email notifications based on a member’s status as an active or non-active user in WishList Members - while maintaining the user’s settings regardless of member status.


We had solved problem #1 using only SimplePress and WishList Members, but our solution for problem #2 was less ideal.


We originally used Google Groups to send email notifications for forum posts. However, members in Google Groups did not automatically update according to WishList Members, and we needed to manually update the Google Groups - with 300 separate registrations occurring throughout a given year, this was quite tedious. Additionally, using Google Groups members were being directed off our website to manage their forum notification settings, which were also very confusing.


Given that access to the forum is by paid membership and the forum is our primary notification center, we wanted to ease access for our members to receive notifications, which led to a third issue in need of solving; (3) auto-subscribing new members and maintaining forum settings for members who choose to lapse their membership for a period of time before renewing.

Solution - Summary


We expanded Simple Press beyond the forum and integrated two Simple:Press add-ons (plug-ins); Subscriptions and Member Subscribe. These provide the following functions:

  • Active members can manage
    their forum email notifications settings from within the forum instead of from
    Google Groups
  • Non-active members will
    maintain their forum subscription settings, but will not receive emails. When
    they reactivate, they will once again be sent notifications without having to
    set up their account again.
  • New members are
    auto-subscribed to our forums.

Step-By-Step Solution - Forum Website and WishList Members


These are the instructions needed to solve problem #1, configuring WordPress, WishList Member and Simple:Press to restrict access to the forum website. These settings must be in place before we could tackle problems #2 and #3.


1. Configure WordPress to set the New Default User Role to Subscriber.


2. Set up WishList Member Levels. The Active Level is used for current paid members who will have access to the website (see step #3), and Expired Level is all past members that have not paid the current calendar year’s membership fee. They do not have access to the forum.


2a. Configure WishList Members Active and Expired levels. For the Active level, the Access To settings should be checked for All Posts, All Pages, All Comments, All Categories. It’s most important that All Pages is checked. For the Expired level the Access To settings should NOT be checked for All Pages.


3. Set up SimplePress User Groups. All members have equal access to the website and forum so we have a single group called Members. Therefore it is the Default usergroup for new members.


3a. Configure SimplePress Permission Sets. Since access is either full or none for members and non-members, we only needed one permission set. We deleted the others and only used Standard Access.


3b. Connect User Groups and Permission Sets. For each forum (we only have six forums), we connected the Members User Group and Standard Access Permission Set.


4. Set up the WordPress page for the forum. Since all active members have equal access to the forum, we utilize WordPress Pages and WishList Member levels to limit access to the forum by limiting the whole page. We’ve created our Brooklyn Tri Club Forum Page here:


4a. Configure members-only access to forum Page. At the bottom of the Forum Page, set the Protection and Access to Protected. Earlier, we set the Active level to have Access to All Posts and Pages. This setting will prevent access to this page for everyone except Active members.


4b. Finally, in SimplePress’s settings, go to Integration and set the Permalink to the Page you just set up.


With this setup, when a user
is added to the Active level in
WishList Members, they will gain access to the forum page. And when a member is
moved from Active to Expired, they will no longer be able to access the forum
page.

Step-By-Step Solution:
Connect WishList Members to SimplePress Subscription


These are the instructions needed to solve problem #2 - handling expired members.


If a membership expires, we keep their account but move them into an ‘Expired’ level in WishList Members. In this way if they sign up again in the future all their account settings are retained. However, we only want to send out email notifications to active members, so we need to extend SimplePress to check if the WishList Member does NOT belong to our ‘Expired’ level before sending an email to them. This requires writing a bit of code into our Theme’s “custom-functions.php” file to connect the two plugins together.


1. We can do this by hooking into the SimplePress subscriptions plugin actions ‘sph_subscriptions_combined_list’ and ‘sph_subscriptions_digest_list’ .

 
add_action('sph_subscriptions_combined_list', 'on_get_users_for_email');

add_action('sph_subscriptions_digest_list', 'on_get_users_for_email');

function on_get_users_for_email($user_ids) {
   $expiredIds = get_wlm_ids_by_level_name("Expired");
   $user_ids_to_email = array_diff($user_ids,  $expiredIds); 
   return $user_ids_to_email;
}


In this snippet we are
connecting our function up to the SimplePress actions. First we get a list of
all our WishList Member users that are in the ‘Expired’ level. Then we use the
php function array_diff() to return an array of user
IDs that are not in the expired
level.


1a. Our custom function get_wlm_ids_by_level_name() looks like this:

function get_wlm_ids_by_level_name($level_name) {
   $levels = wlmapi_get_levels();
   foreach ($levels['levels']['level'] as $key => $value) {
      if(strtolower($value['name']) == strtolower($level_name)) {
         $level_id = $value['id'];
      }
   }
   $level_members = wlmapi_get_level_members($level_id);
   return array_column($level_members['members']['member'], 'id');
}


1b. This uses WishList Member’s API function wlmapi_get_levels() which returns an array of ‘level’ objects. Each of these objects contains properties we can read and compare against. For each level we get from the API, we check if the ‘name’ of the level matches the name we are looking for. We then take the ID of the found level, and pass it to wlmapi_get_level_members() which will return a list of ‘member’ objects that match the level ID. From there we can get an array of member IDs by using array_column.


With these actions in place,
when SimplePress goes to compile a list of users to send emails to, we will
filter out anyone who is in the ‘Expired’ level. If that user decides to
register again, they will be moved from the Expired
level to the Active level, and will
not be filtered out of the subscription emails.

Step-By-Step Solution: E-mail
Notifications Auto-Subscribe


These are the instructions needed to solve problem #3 - ensuring alerts only go out to active members.


For our site we send out email notifications using SimplePress’ Subscriptions, HTML emails, and Member Subscribe plugins.The forum is only accessible by paid access, and so by default we want to automatically subscribe users to all forums and allow them to opt out if they would like.


This is a somewhat unusual behavior - normally you want users to opt in, but in our case signing up for a membership is considered opting in. So to achieve this we needed to extend the SimplePress user creation process.


1. We can do this with a Wordpress action hooked into “sph_member_created”.

add_action('sph_member_created', 'on_forum_member_added');

function on_forum_member_added($userid) {
   $forums = get_all_forums();
   foreach($forums as $f) {
      add_forum_subscription($f->forum_id, $userid);
   }
}


This snippet simply hooks up
our custom process to user creation. This function will get a list of all
forums our site defines and then for each forum, add a subscription for the new
user.


2. We get a list of all forums directly from our database with the following function:

function get_all_forums() {
   global $wpdb;
   $sql = 'select * from ' . $wpdb->prefix . 'sfforums order by forum_seq';
   $forums = $wpdb->get_results($sql,OBJECT);
   return $forums;
}


3. We then add the forum subscriptions with the following (keep in mind this requires the Subscriptions plugin):

function add_forum_subscription($forumid, $userid) {
  if (!$userid || !$forumid) return '';
  SP()->activity->add($userid, SPACTIVITY_SUBSFORUM, $forumid, '', false);
}

Special Notes


Our forum is configured so that access settings are binary - there is only full access or no access. This lets us keep our user groups, and permissions pretty simple within Simple:Press and WishList Members.


Brooklyn Triathlon Club is a close-knit community where all members know each personally, and so we wanted to include email addresses in forum post notifications, giving members the option to private message each other easily. This is not available by default, so we added a custom filter to “sph_subscriptions_notification_email”, in our WP theme to achieve this.

add_filter('sph_subscriptions_notification_email', function($msg, $newpost, $user, $type) {
   $body = str_replace('%USEREMAIL%', $newpost['posteremail'], $msg);
   return $body;
  }, 10, 4);


This filter will modify the contents of the notification email before it is sent out. Here we simply replace a specific string “%USEREMAIL%” with the poster’s email. This works in a very similar way to Simple:Press’ normal placeholders for HTML emails.

Other Modifications of Interest


The default Simple:Press theme is a bit dated so we added a bit of styling to modernize the UI a bit. Below are a few images of the current forum (both desktop and mobile). Click on any image in the gallery for a much better view!

Wrap Up


We integrated SimplePress and
WishList Members in two parts. First via the website, and involved simply
configuring settings across both plug-ins and WordPress. However, it is a
necessary foundation for the second integration of SimplePress and WishList
Members, e-mail notification settings for forum posts for active and non-active
members. Our integration can be summarized as follows.


1. Foundational Integration: Integrating SimplePress with WishList Members to limit access requires enabling permission sets within WLM, WordPress and SimplePress. You simply Protect the Page that the forum page is permalinked to.


2. Extended Integration: We extended SimplePress and WishList Member integration further by only sending forum email notifications to active members based on their current Level in WLM. We are able to maintain their subscription settings even when members lapse their membership.

Bio


Vicky Wei is an avid triathlete with a casual passion in website development. When she’s not training and racing and working on websites, she’s building investment models in the fund-of-funds world.

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626