Membership Plugin - problem with creating access to sections

By JeffC - January 20, 2014

I would like to use the membership plugin to allow users to create a cms account and create one page in a section on my website. The table name is 'friends' and they should have access to create and edit one page only.

The user is created but access is not granted in the cms. When I look at the user accounts area of cms the section access is set as 'none'. If I manually change that to 'by section' I can see that the friends table is set to 'Author' and the max records is set to '1' but how do I automatically set this up so that section access is set to 'by section' when the new account is added?

Furthermore when a new account is set up via the membership plugin no expiry date is set. I would like the check box to be set as 'account never expires'

This is the code I am using:

// set access rights for CMS so new users can access some CMS sections
$setAccessRights = true; // set to true and set access tables below to use this
if ($setAccessRights && accountsTable() == "accounts") { // this is only relevant if you're adding users to the CMS accounts table

// NOTE: You can repeat this block to grant access to multiple sections

        mysql_insert('_accesslist', array(
          'userNum'      => $userNum,
          'tableName'    => 'friends',   // insert tablename you want to grant access to, or 'all' for all sections
          'accessLevel'  => '6',         // access level allowed: 0=none, 6=author, 9=editor
          'maxRecords'   => '1',          // max listings allowed (leave blank for unlimited)
          'randomSaveId' => '123456789', // ignore - for internal use
        ));

Note, when I first installed the membership plugin I hadn't realised I was running cms 2.51 and it requires min 2.52. I have now upgraded cms to 2.53 but still experiencing the problem.

Jeff

By JeffC - January 21, 2014 - edited: January 21, 2014

Hi Chris

The 'Never Expires' part of the problem has been solved - thank you

The Access By Section solution that you provided hasn't fixed my problem. After creating a new user using user-signup.php the access granted is still 'none' in the cms. Any other ideas?

Thanks
Jeff

CORRECTION: Your solution to my 'Access By Section' problem does work with a small amendment. In your supplied code below change maxRecords from blank to 1

// Access = By Section
mysql_insert('_accesslist', array(
  'userNum'      => $userNum,
  'tableName'    => 'all', // insert tablename you want to grant access to, or 'all' for all sections
  'accessLevel'  => '1', // access level allowed: 0=none, 6=author, 9=editor
  'maxRecords'   => '1', // max listings allowed (leave blank for unlimited)
  'randomSaveId' => '123456789', // ignore - for internal use
));

Thanks for your help.

Jeff

By Chris - January 21, 2014

Hi Jeff,

Great to hear! Let us know if you have any more questions! :)

All the best,
Chris