Latest Register Log In

+ Advanced Search

Member system integration

Member system integration
By
10/17/03 (Edited 03/10/14)

If you wish to use an existing member database, such as one from a forum, you can usually do that. Go to Admin -> Members -> Integration and check the list of pre-supplied integration files. If the script you need to integrate with is on the list, select it there. If it's not in the list, you'll need to use the integration generator on the same page. The integration generator will work for most common script designs, but it's impossible to anticipate every member system format so you may need to contact WSN support for help with your specific system.

Mapping Usergroups

Since different types of scripts have different types of permissions, there's no logical way to integrate usergroup permissions -- instead, we map a usergroup number from the other script to be treated as an equivalent WSN usergroup number. You can find your WSN usergroup numbers at Admin Panel -> Members -> Manage Usergroups -> (select a group) at the top.

By default, only the basic usergroups are mapped: guests, members, administrators. All other groups are considered as members. You can change this to map more of the other script's groups onto WSN groups. Open the integration file (in the /integration/ subdirectory) in a text editor. You can map groups by adding lines in the form
$group4 = '6';

This example specifies that everyone in group #6 of the member system you're integrating with will be treated as being in WSN group #4. Create a group #4 in your WSN admin panel and give it the permissions you want members in group 6 of your other database to have.

This can be continued for multiple groups by adding more lines, like
$group5 = '10';
to set group 10 to work as WSN usergroup #5.

For Advanced Users

Continue reading this manual entry only if you have problems with the integration generator not fully supporting what you want to do, or you or just want to learn more about how integration works.

To get an idea of what you're trying to do, have a look at /integration/setup/smf.php. That file has a bit of everything -- various special functions to handle the awkward cases SMF presents. You may find it useful to copy from there to your integration file. Note that any .php file you save to the integration directory will automatically become a selectable option in your settings (except ones named with 'encoder' in the title, as will be explained in a moment).

The format of the integration files is simple. First you specify the name of the database table, as $memberstable = 'otherscriptstable';
Look at otherscriptstable in phpmyadmin, write down the field names listed for it and be sure you have a general idea of what each field contains or is for. Then specify in the integration file each field in that table which does NOT have the same name as the corresponding item in the WSN Links members table (compare with yourprefix_members in phpmyadmin). The format for this specification consists of putting $new in front of the WSN field name, and then = "the other script's field name we should use";

For example:
$newname = 'username';
$newid = 'userid';

Fields which are named the same as in WSN Links do not have to be specified.

All WSN member fields which do not exist in the script you're integrating with will be automatically added as soon as you load any page on your site with that integration script selected.

Note: Do not drop the WSN members table when done, because it is still used for field comparisons, upgrades, etc.

If for some reason the administrator is identified using something other than the usergroup field, you can set $adminfield = 'fieldname'; and $adminfieldvalue = 'whateverthefieldhasforanadmin';... you could do this with a username field to set just one member as admin for example.

If your script uses an array for the user/password cookies, just supply the name (without an index) as the cookie name and password, and then add this to your integration file:

$cookietype = 'array';
$idindex = 'userid';
$passwordindex = 'password';

Of course replacing userid and password with the actual index names for the array cookie. If it uses a member username instead of an id, add:

$cookieidtype = 'name';

See the integration/setup/mambo.php file as an example.

When dealing with session cookies, you can use $cookietype = 'session'; and add a
$sessionquery = "SELECT x FROM y WHERE id='{SESSIONID}'";
line to specify the query needed to get the member id when given the session id. Put the session cookie name in the $idcookiename spot.

If you set $registrationurl = 'http://hostscript/register.php'; then people will be automatically directed to the registration page of the host script, and avatars will be automatically shared for WSN scripts.

Sometimes you may run into a member system which doesn't keep all the member data in the same table. As of 5.0.0, you can handle this by manually specifying the additional fields ($newsomething = 'something' as above) and then adding this line:
$integrationoptions['queryadditionalfields'] = "SELECT field1,field2,field3 FROM othertable WHERE id='{ID}'";

You need to alter the query to specify how to get data out of the particular table you're dealing with. Note that this method will get the data out of the fields, but won't allow updating the values of the fields by editing a WSN profile.

Additionally, if you need to get the member usergroup out of another table with a custom query, you can specify that like this:
$integrationoptions['usergroupquery'] = "SELECT group FROM othertable WHERE id='{ID}'";


Helper Functions

Helper functions can be used for the registration and cookie setting/unsetting processes. Look at integration/smf.php for an example implimentation of each, copy that and modify to your needs.

integratedregistration - If you want to allow registering through the WSN interface instead of redirecing to the other script's registration page, you can do that and put cleanup code here to make the database correct for the other script's use.

setlogincookies - If cookies needs to be set in some unique way, or a database session needs to be added to the database in the process, do that here.

unsetlogincookies - In case you need a special way to clear the cookies on logout (perhaps deleting a database session).

comparecookiepassword - If your script has a special way of deciding whether the value in a password cookie is authentic, you can specify it here.

integration_extractcookie - Get the id and password out of the cookie.

integration_encodepassword - Special password encoding. This used to be done as a separate xencoder.php file.

Troubleshooting

If you choose an integration option and it does not function, run this query in phpmyadmin to go back to the native member system so that you can login again:
UPDATE yourprefix_settings SET content='' WHERE name='integration';

Change yourprefix_ in that query to whatever tables prefix you selected to use during setup. You will then need to visit upgrade.php (no need to run the upgrade, just view the page) to get the field list reset.

After you set or unset the integration, note that you will likely need to go to Settings -> General Appearance and re-select a member list sort order (this is so that it sorts by a field which exists in your new members table). Also select a valid member sort order for member searches under Settings -> Search & SEO.

Integrating With Other WSN Scripts

When integrating with another WSN script, you automatically share stylesheets, online user lists, private messaging and instant messaging systems. You can also share templates and toplist data.

For details on integrating with other WSN scripts, please see the full article Integrating With Other WSN Scripts.




Description Using WSN with a preexisting member base.
Rating
Views 13598 views. Averaging 2 views per day.