The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Only Admin can create new accounts - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 3 (https://userspice.com/forums/forumdisplay.php?fid=25)
+--- Thread: Only Admin can create new accounts (/showthread.php?tid=51)



Only Admin can create new accounts - andy - 02-05-2016

Hello

I am trying to only allow admin user to create new user accounts. I took a copy of register.php, and removed the line if logged in die. However when you create an account it doesn't work. No error, just fails. I have been looking through the User.php class as I guess the problem is in the userCakeAddUser() function or User class somewhere, but I can see where it might be.

I am a PHP novice, learning as I go!

Any suggestions appreciated!

Andy


Only Admin can create new accounts - mudmin - 02-05-2016

You're going to laugh when I tell you this, but the best way to do this is to let UserSpice do it for you. No coding required. Login as administrator, and go to Admin Pages. Click on register.php and make it private. Then check the box next to administrator and click update. This will allow only users with administrator access to use the register.php page.


Only Admin can create new accounts - andy - 02-05-2016

Hi, thanks for your reply!

This is actually what I did though. I set my new page (copy of register.php) to be private and only accessible by admin. When I fill out the form the page redirects to account.php, and does not create the new account. The register.php page will keep you on the page and give message that account was created.

Any ideas?


Only Admin can create new accounts - mudmin - 02-05-2016

I'm not in the office today to test this on my own computer but did you make any changes to the registration form other than making it private?


Only Admin can create new accounts - mudmin - 02-05-2016

Ahhh. I see now what you were saying. I was looking at that on my phone. I'll make a create_user form or something and see what I can do. I'll get back to you on that.


Only Admin can create new accounts - mudmin - 02-06-2016

The quick answer is that there isn't an easy way to do this that I can see with the UserSpice code base. That should be something I can add into UserSpice 4 a lot easier. In the short term (and I know this sounds totally ghetto), but you could always add all your users by going directly to register.php and then just rename it to register.bak when you're not using the feature. The other option if you're going to give them all the same starting password is that you can go right in phpmyadmin and add them there. If you want to give them all the password "password", just paste this in as the password. $2y$12$m5AaiWNQLPxKTe.IsNHizuJ0dtQJmhyOJK2v.QxikW9whfbqkPlzG

Sorry I don't have a cleaner way to do it off the top of my head. Part of the reason why I wrote US4 was to get away from the way US3 did things.


Only Admin can create new accounts - andy - 02-06-2016

Hi, thanks for taking a look. At least I wasnt missing anything obvious!

For time being, easiest thing is just to make register private, and then public for the short period I need to create a few accounts.

Thanks for userspice, only discovered it a few days ago and it is a joy to use. Learnt a lot from digging through your code and there are some great video tutorials provided which you dont often see. Makes picking it up and using it a relative breeze for novices like myself!

Cheers

Andy


Only Admin can create new accounts - mudmin - 02-06-2016

I'm glad you're finding it useful. I think UserSpice 4 will be even easier to understand because a lot of the documentation is for that.

I appreciate the encouragement. This has been a huge undertaking and not fun at times!