The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Only Admin can create new accounts
#1
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
  Reply
#2
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.
  Reply
#3
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?
  Reply
#4
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?
  Reply
#5
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.
  Reply
#6
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.
  Reply
#7
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
  Reply
#8
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!
  Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)