
The Payaccess feature allows you to completely disable registration on the board itself, and instead control registration by an external script. This is useful if you wish to only register a user after they have paid a subscription fee, or if you only want them to be able to view the board (or a single forum) after signing up for something else.
To set up Payaccess, view your Admin Area and click the ``Pay Access'' button. You will see a list of all the forums. You can either enable Payaccess for the whole board (click the ``Enable'' link next to ``Whole Board''), or just for a specifc forum (click the ``Enable'' link next to the forum you wish to enable it on).
Remember that users will not even be able to view the board/forum if they have not been approved by Payaccess.
When you've enabled as you wish, scroll to the bottom of the Pay Access screen. You will see a box: Message users receive if they don't have access:. Type in a message that users will see if they don't have access, including a description of how they can sign up or make payment. Type your signup URL (or home page) in the Signup/Payment URL box.
Now it's all set up, you will need to integrate your billing/signup script with the Perl Payaccess API.
Firstly, you need to check the permissions on the bbv2api.pm file in your board's base directory. The default permissions don't even allow it to run, for security purposes. To change that, use your FTP program, or log in via SSH/telnet to your server, and change the permissions on the bbv2api.pm file to 0755. In a *NIX command line, you can do this with:
chmod 0755 bbv2api.pm
The next step involves editing the source code for your billing/signup script. Locate the area of the script where the user has made payment or signed up adequately, and add this code:
require '/path/to/bbv2api.pm'; # Edit the path to be correct for bbv2api.pm
my $bbv2 = new bbv2api;
If the user does not already have an account on your board, you first need to register him:
# Note that a welcome e-mail is NOT sent
my $result = $bbv2->RegisterUser({
username => $username,
password => $password,
email => $email
});
if ($result) {
# Something went wrong - the error as a string is in $result
}
You can then actually allow the user to access the Payaccess forum/board:
my $res = $bbv2->PayAccessSignup($username, $fid);
# $fid is the numerical ID of the forum to allow access to. If you've enabled Payaccess
# for the whole board, you can simply use:
#
# my $res = $bbv2->PayAccessSignup($username);
if ($res) {
# Something went wrong - the error as a string is in $res
}
The user can then access the board/forum, when they're logged in.
Advanced programmers may also want to set the cookie so the user is automatically logged into the board, or send them further details.
The bbv2api.pm module also provides:
$bbv2->PayAccessDelete($username, $fid); # Removes the user's access
$bbv2->PayAccessList($fid); # Returns an array of UIDs with access to that
# forum, or the whole board if no $fid is specified
$bbv2->PayAccessQuery($username, $fid); # Returns 1 if the user has access, or
# 0 if he doesn't
|