Limit User Creation

Good stuff!

Thanks! Couldn’t have happened without your help :slight_smile:

Is this script still valid for the current version. When I use it it doesn’t work - I just get the following error - and it happens whether I have reached the limit or not. And it doesnt redirect it just shows error. I did a repair and rebuild after creating the hook and the file.

class limit_users { function limit_user_count(&$bean, $event, $arguments) { $query = "SELECT id FROM users WHERE deleted = 0"; $result = $GLOBALS->query($query); while($row = $GLOBALS->fetchByAssoc($result)) { $id[] = $row; } if($_POST["record"] == NULL && count($id) >= 10) {//checks if the entry is new and records are not more that 10 SugarApplication::appendErrorMessage('Action Prohibited: Maximum number of users created.'); $params = array( 'module'=> 'Users', 'action'=>'ListView' ); SugarApplication::redirect('index.php?' . http_build_query($params)); exit; } } }

OK Andy your script worked - Sid I could’nt get yours to work,