Membership Plugin - problem with creating access to sections

By Chris - January 20, 2014 - edited: January 20, 2014

Hi Jeffncou,

I looked at the rows that CMS Builder creates when you set a user up with Access = By Section and one of the section's to Author with Max Records = 1. It seems that there's a row with tableName = 'all' and accessLevel = '1', so I'd recommend inserting that row to see if that clears up the problem. Add this first _accesslist mysql_insert above your existing _accesslist mysql_insert (which I have not changed). New code in red:

// 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'   => '', // max listings allowed (leave blank for unlimited)
  'randomSaveId' => '123456789', // ignore - for internal use
));

// friends = Author (max records = 1)
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
));

You can set the Never Expires checkbox for new users by adding a line of code before the account record is inserted in the accounts table. There's only one new line of code here, but I'm showing the nearby lines of code for context. New code in red:

$colsToValues['password']         = $passwordHash;
// ... add more form fields here by copying the above line!

$colsToValues['neverExpires']     = '1';

$userNum = mysql_insert(accountsTable(), $colsToValues, true);

Please let me know if this helps!

All the best,
Chris

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