Overview

Introduction

If you use MemberMouse for your WordPress membership website, wpForo can be a great solution if you want to have a forum for your members.

The integration of MemberMouse and wpForo is pretty straightforward.

These two plugins use some of WordPress database data and therefore the integration comes naturally.

But even so, some changes are needed in order to have a full integration.

Video Tutorial

Install wpForo Forum on WordPress

First of all let’s install wpForo.

Installation process it is the same as for the other plugins.

1 – Go to WordPress Dashboard > Plugins > Add New.

2 – Search for wpForo and Install, then activate the plugin.

The basic settings to integrate MM with wpForo

Once wpForo is installed, just go to Forums > Settings and click on Members tab.

wpForo has many options, but in this article we will cover just a few which are needed in order to have a smooth integration with MemberMouse.

If the login page for MemberMouse members is something like http://yourdomain.com/login/, then choose the same URL for “Custom Authorization URLs” – Login URL.

This way, users will login to MemberMouse and wpForo at the same time.

For “Members URL structure” you can choose either “USER_ID” one or “USER_NICENAME“.

Later I will describe the issue with the forum member profile pages in the case that you choose “USER_NICENAME“.

…and the solution to fix that issue… 🙂

These two are the most important settings for this integration.

Next we will see the issues which will appear when users will update their account details from inside their MemberMouse account page.

How to fix user “Update Account Details” issues

When MemberMouse members update their account details you will notice that these do not work correctly.

As I wrote above, if you choose members URL structure to be based on user nicename, that will not work properly.

When a user changes the username from MemberMouse account page, the links to wpForo member profile pages will give you a 404 error.

That is because wpForo data is not updated when this happens.

Also, if a user updates the first name or last name, these changes will not be reflected in his wpForo profile pages.

Here’s our solution for this.

Step 1 – Create a PHP script to update wpForo user settings

a. You will need to create a PHP file, name it change-mm-username-update-nicename.php and add the following code to it:

php

  if(!isset($_GET["member_id"]) || empty($_GET["member_id"]))
  {
  exit;
  }

// wp core functionality
  $absPath = dirname(__FILE__);
  $realPath = realpath($absPath . '/./');
  $fPath = explode("wp-content",$realPath);
  define('WP_USE_THEMES', false);
  require(''.$fPath[0].'/wp-blog-header.php');

// get member ID
  $memberId = $_GET["member_id"];

global $wpdb;

// get user nicename
  $user_nicename = $wpdb->get_var("SELECT user_nicename FROM wp_users WHERE ID = '$memberId'");

// if first name and last name are updated from MM account, they are only updated in MM member data table; we need to update them in wp foro too
  $user_first_name = $wpdb->get_var("SELECT first_name FROM mm_user_data WHERE wp_user_id = '$memberId'");
  $user_last_name = $wpdb->get_var("SELECT last_name FROM mm_user_data WHERE wp_user_id = '$memberId'");

//prepare display name for wp foro
  $user_display_name = $user_first_name.' '.$user_last_name;

echo $user_display_name;

// get serialized data from wp_usermeta table where the nicename it's not updated
  $wpf_member_obj = $wpdb->get_var("SELECT meta_value FROM wp_usermeta WHERE user_id = '$memberId' AND meta_key = '_wpf_member_obj'");

$wpf_member_obj = unserialize($wpf_member_obj);

var_dump($wpf_member_obj);

// update all values in unserialized 
  $wpf_member_obj["user_nicename"] =$user_nicename;

// serialize data and update it in the database
  $wpf_member_obj = serialize($wpf_member_obj);

$wpdb->update( 
  'wp_usermeta', 
  array( 
  'meta_value' => $wpf_member_obj 
  ), 
  array( 'user_id' => $memberId,'meta_key' => '_wpf_member_obj' ), 
  array( 
  '%s'
  ), 
  array( '%d','%s'  ) 
  );

// change the display name in wp_users , if it was changed in MM

$wpdb->update( 
  'wp_users', 
  array( 
  'display_name' => $user_display_name 
  ), 
  array( 'ID' => $memberId ), 
  array( 
  '%s'
  ), 
  array( '%d'  ) 
  );

The above code updates wpForo profile display name and profile links for the member.

It will be triggered by a MemberMouse Push Notification as I will explain below.

b. Then add the file to your theme folder (https://yourdomain.com/wp-content/themes/your-child-theme-folder).

Obviously your child theme folder directory probably won’t be named “your-child-theme-folder”. 🙂

IMPORTANT: I highly recommend that you first create a child theme, or use the My Custom Functions WordPress plugin whenever you add custom code to your theme files. Otherwise, any time you update your theme your changes will get wiped out!

Step 2 – Create a MemberMouse Push Notification

After the PHP file is created and uploaded to FTP, we will need a way to TRIGGER the code right after the user account details are updated.

And for this we will create a MemberMouse Push Notification.

a. Log in your WordPress dashboard and go to MemberMouse > Developer Tools.

b. Click on “Create Push Notification” green button and add the below settings:

c. The URL to your custom script will be:

https://yourdomain.com/wp-content/themes/your-child-theme-folder/change-mm-username-update-nicename.php.

d. Click on “Save Push Notification” and… that is all! Now you have a full integration of MemberMouse with wpForo.

e. Want our team to do this integration for you?

No problem, just visit our MemberFix product information page and sign up or get in touch for a call!

 

What do you think of this article?

Article Title: How to integrate MemberMouse with wpForo

Short Description: Learn how to fully integrate MemberMouse with wpForo.

Publisher Logo:

Sending

User Review

5 (1 vote)

 

Share This