Frank Vèssia Posted September 4, 2014 Share Posted September 4, 2014 I need to remove a field from user template, the problem is I have more than 40.000 registered users and every time i tried to remove the field from the admin I got a sort of crash and the result is the field was not removed. Is there a way I can remove it manually directly from the database? Which tables I have to check? Thanks Link to comment Share on other sites More sharing options...
cstevensjr Posted September 4, 2014 Share Posted September 4, 2014 I would advise that you go into maintenance mode (offline) and then you should be able to remove the field from the template without a problem. That should eliminate everyone but the superadmin accounts from accessing the website. http://modules.processwire.com/modules/maintenance-mode/ Link to comment Share on other sites More sharing options...
kongondo Posted September 4, 2014 Share Posted September 4, 2014 (edited) You can also remove the fields using the API.... Backup your site first, please! This was written in a function context so feel free to change it and use in a template file context. You could also wrap the code in a conditional if $user->isSuperuser... Changed and done... if ($user->isSuperuser()) { //first remove the fields from 'user' template before deleting them. $t = $templates->get('user'); $fg = $t->fieldgroup; $fg->remove($fields->get('your_field')); $fg->save(); //delete the fields $f = $fields->get('your_field'); $fields->delete($f); } Edited September 4, 2014 by kongondo Changed code to template file context 8 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted September 4, 2014 Author Share Posted September 4, 2014 Thanks, I didn't think to use the API... Link to comment Share on other sites More sharing options...
pwired Posted September 4, 2014 Share Posted September 4, 2014 Learned some good api code today, saved in my snippet folder. Link to comment Share on other sites More sharing options...
ryan Posted September 4, 2014 Share Posted September 4, 2014 So long as the field isn't a repeater, file/image, or PageTable, PW 2.5 (2.4 dev) can do it in one query, which should take about a second. PW 2.4 and prior cycled through each page to delete a field. So that could be a slow process, though it is a good process. PW 2.5 still has to cycle through every file/image or repeater/pagetable field since they all involve external assets that also need to be deleted. But if the field you need to delete isn't one of those, you may want to consider waiting for PW 2.5 since we may soft launch it as soon as next week. Or you could try out the dev branch locally to test things out and see if you want to use it live. 5 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted September 4, 2014 Author Share Posted September 4, 2014 yeah, i'm still using 2.3 for this project. It's quite risky to upgrade PW at this point (40k users, almost 3k logins per day), I made it in the past and I had some little problems, even during the night users are always connected doing stuff (it's a social network), moreover I made a big modification since I had the 32k files limit problem, solved with Wanze's solution ...but I need to change server very soon, maybe I can wait 2.5, copy the site to the new server, upgrade PW, reapply the mod and if everything looks ok switch dns...thanks anyway Link to comment Share on other sites More sharing options...
adrian Posted September 4, 2014 Share Posted September 4, 2014 yeah, i'm still using 2.3 for this project. It's quite risky to upgrade PW at this point (40k users, almost 3k logins per day), I made it in the past and I had some little problems, even during the night users are always connected doing stuff (it's a social network), moreover I made a big modification since I had the 32k files limit problem, solved with Wanze's solution ...but I need to change server very soon, maybe I can wait 2.5, copy the site to the new server, upgrade PW, reapply the mod and if everything looks ok switch dns...thanks anyway I believe Wanze's solution to the filesystem limit problem has been added to the dev core: https://github.com/ryancramerdesign/ProcessWire/issues/432#issuecomment-40951719 1 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted September 4, 2014 Author Share Posted September 4, 2014 Amazing, I will take a look Link to comment Share on other sites More sharing options...
kongondo Posted September 5, 2014 Share Posted September 5, 2014 yeah, i'm still using 2.3 for this project. It's quite risky to upgrade PW at this point (40k users, almost 3k logins per day), I made it in the past and I had some little problems, even during the night users are always connected doing stuff (it's a social network), moreover I made a big modification since I had the 32k files limit problem, solved with Wanze's solution ...but I need to change server very soon, maybe I can wait 2.5, copy the site to the new server, upgrade PW, reapply the mod and if everything looks ok switch dns...thanks anyway This sounds like a good case study for PW...if you could do a write-up about creating a social network site with PW that would be great . Btw, when ready to migrate to 2.5, are you saying you couldn't even warn users in advance that the site will be offline for a set number of hours? 2 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted September 8, 2014 Author Share Posted September 8, 2014 Well, this social network is a result of more than 2 years of development (alone), I can write something about but I'm not a top level programmer , I'm pretty sure a lot of stuff I created can be made in a better way.I can stop the website few hours in the night...anyway I'm migrating to a better server so I will make all the test there and when ready move everything. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now