What exactly is it that doesn't work?
I installed a brand new test site with
CMS Made Simple 1.9.4.2 "Faanui"
CGExtensions 1.26.3
SelfRegistration 1.6.10
FrontEndUsers 1.12.16
Uploads 1.12
CustomContent 1.7.3
I had some problem with SelfRegistration even before I installed any of my own code, it looks like I've hit bugs 6705 & 6499.
(If they are bugs, could be some misconfiguration as well).
http://dev.cmsmadesimple.org/bug/view/6705
http://dev.cmsmadesimple.org/bug/view/6499
Anyway, I got around that by deselecting
"Require the user to confirm registration via email"
in the SelfRegistration preferences.
Now it seems you must have at least one group defined in FrontEndUsers to be able to create users, and to create a group you need at least one property.
So if you don't have any existing groups and properties you can create some dummy values. I created a group called Users and set that as the default for new users.
Create an UDT with the following content:
Code: Select all
$gCms = cmsms();
$propname="x";
#The name of an existing FrontEndUser property to assign to the new group.
#Could be a dummy property.
#If no property is assigned to the group there will be an error when trying to edit the group.
if (!$gCms->modules['Uploads']['object']) {return;}
$feu = $gCms->modules['FrontEndUsers']['object'];
if (!$feu) {return;}
$uname = $params['name'] ? $params['name'] : $params['username'];
$uid = $params['id'];
if (!$uname || !$uid) {return;}
$result=$feu->AddGroup( "User_" . $uname, "Group for user " . $uname);
if (!$result[0]) {return;}
$gid=$result[1];
if (!$feu->AssignUserToGroup( $uid, $gid)) {return;}
if (!$feu->AddGroupPropertyRelation( $gid, $propname, 1, -1, 1)) {return;}
$db =& $gCms->GetDb();
$category_id= $db->GenID( cms_db_prefix () . "module_uploads_categories_seq");
$category_name = "User_" . $uname;
$category_desc = "User category for " . $uname;
$category_path = "User_" . $uname;
$category_listable = 1;
$category_deletable = 0;
$category_expires_hrs = 0;
$category_scannable = 0;
$query = "INSERT INTO " . cms_db_prefix() . "module_uploads_categories
(upload_category_id, upload_category_name, upload_category_description,
upload_category_path, upload_category_listable, upload_category_deletable,
upload_category_expires_hrs, upload_category_scannable, upload_category_groups)
VALUES (?,?,?,?,?,?,?,?,?)";
$dbresult = $db->Execute( $query, array (
$category_id,
$category_name,
$category_desc,
$category_path,
$category_listable,
$category_deletable,
$category_expires_hrs,
$category_scannable,
$gid));
if (!$dbresult) {return;}
$conf =& $gCms->GetConfig();
if (!mkdir( $conf['uploads_path'] . "/" . $category_path, 0777)) {return;}
The file permissions in the mkdir command could perhaps be set tighter than 0777, depending on your server setup.
Next, attach that UDT to event OnCreateUser in module Frontend User Management, and to event onUserRegistered in the Self Registration Module.
Then, create a login page something like this: (Turn of WYSIWYG & caching)
Code: Select all
{cms_module module=FrontEndUsers}
{if $ccuser->loggedin()}
{cms_module module=FrontEndUsers form=changesettings}
{else}
{cms_module module=SelfRegistration group=Users}
{/if}
The group name should be of an existing group.
Create an upload page something like this: (Turn of WYSIWYG & caching)
Code: Select all
{if $ccuser->loggedin()}
{Uploads mode=upload category=User_$customcontent_loginname}
{else}
You must log in
{/if}
That works for me, both for users created by the admin and for users creating themselves using SelfReg.
You must have all the modules listed at the top of this post installed.
Note that this is just a base. For example, error handling is missing, and there is no protection against user names that might contain characters invalid (or undesirable) in directory names.