Topic: Test forum/group membership

I've got an additional app I have written in php.  The PHP is pretty rudimentary.

The App is located at something like domain.com/app

I've got a PunBB forum at location domain.com/forum

I would like to limit use of this app to just members of a specific group of members of my PunBB forum. 

So what I'm looking for is a relatively easy way to simply check if they are members of a punBB group - if they are, letting them move forward.  If they are not (or if they are not logged in) sending them to a login page.

However, I'm having a hell of a time finding out how to do that.

Can anyone help?

Re: Test forum/group membership

(ps.  I can actually get the username and group membership (which I can then test against)) but when doing so I get errors.

here is the code I'm inserting

<?php
if (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', '../forum/');
require FORUM_ROOT.'include/common.php';

($hook = get_hook('in_start')) ? eval($hook) : null;
    
// Show login if not logged in
    if (is_null($forum_user['username'])) {
    echo 'You are not currently logged into the forum... <a href="../forum/login.php">please do so</a> and return';    
    } else {
        if ($forum_user['group_id'] == 4) {
            echo $forum_user['username'].', you are authorized to use the system...';    
        } else {
            echo 'You are not at the correct membership level to use the system.  Upgrade today!';
        }
    }
?>

If I am logged in, this works.   It will filter out correct groups and give the correct messages.  However, I get two "Warning: Cannot modify header information ...." errors showing up on the page.

If I am not logged in, I do not get the errors... but I also do not get the right message.  I would like to get a "you are not currently logged in..." message.  Instead, I get the "you are not at the correct membership level" message.


Thoughts or nudges in the right direction?

Thanks in advance for any help...