Gossamer Forum
Quote Reply
APIs for the users table
We are going to lauch a new web site in June and would like to integrate the forum as part of
the new web site. We maintain our own users table and would like the forum username/password to be a part of this, meaning we would like to have just one login.
Does Gossamer have APIs for updating a user profile, login, removing a user from the forum, etc...?
Quote Reply
Re: [qbudnick] APIs for the users table In reply to
You can access the user's data through GForum's User table object, then perform updates/etc. with this object. From an external source, you'd need to use the following Perl code:

Code:
use lib '/path/to/gforum/admin';
use GForum qw/$DB/;
GForum::init('/path/to/gforum/admin');
my $user_table = $DB->table('User');
Then to update one or more profile columns, (password and aim account ID in the example below), you would then use the following code:

Code:
$user_table->update({ user_password => $new_password, user_aim => $new_aim }, { user_id => $existing_user_id });
If you only have the username, rather than the user_id, you would use this instead:

Code:
$user_table->update({ user_password => $new_password, user_aim => $new_aim }, { user_username => $existing_username });
Of course, you can specify any number of columns to update in the first part, corresponding to the database rows. Note for the password and temporary password rows in particular that the plain-text password should be used - it will be automatically encrypted as required based on your GForum admin panel settings.

To delete a user, you would use:

Code:
$user_table->delete({ user_id => $existing_user_id });
or

Code:
$user_table->delete({ user_username => $existing_username });

Interfacing this with your existing system depends on a number of things, such as what programming language your existing user management system is written in and how easily it is to add Perl code to it (if not Perl, then perhaps by creating a small Perl script that calls the code above).

Please let me know if you have any questions about the above; if you have more complex needs or would like us to write this for you, we can give you a quote for the custom work needed.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com