OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



creating new users via DB insert

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

creating new users via DB insert

Postby jwtlake » Wed Aug 07, 2013 12:54 pm

Is there any reason why I couldn't or shouldn't automate new user creation by making a script that does direct inserts into OJS's 'users' table.

I know there is a plugin available that allows for xml import but I'm looking to integrate with a third party system and a direct insert seems like a cleaner solution to me.

Thanks!
Jonathan
jwtlake
 
Posts: 8
Joined: Mon Jul 29, 2013 8:58 am

Re: creating new users via DB insert

Postby asmecher » Wed Aug 07, 2013 1:52 pm

Hi Jonathan,

That should work just fine. The tables you'll mostly need to concern yourself with are "users" and "user_settings"; I suggest creating a sample user to see how content is represented, particularly in user_settings.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: creating new users via DB insert

Postby jwtlake » Wed Aug 07, 2013 2:47 pm

Thanks.

How about assigning new roles?
I found the 'roles' table which has journal_id, user_id, and role_id
But i haven't been able to find the role_id table. Where are role types stored?

~Jonathan
jwtlake
 
Posts: 8
Joined: Mon Jul 29, 2013 8:58 am

Re: creating new users via DB insert

Postby asmecher » Wed Aug 07, 2013 2:52 pm

Hi Jonathan,

Role IDs are constants; they're defined in classes/security/Role.inc.php.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: creating new users via DB insert

Postby jwtlake » Wed Aug 07, 2013 5:16 pm

Thanks!
jwtlake
 
Posts: 8
Joined: Mon Jul 29, 2013 8:58 am

Re: creating new users via DB insert

Postby jwtlake » Fri Aug 09, 2013 12:31 pm

So before i try my tool out and preform an actual insert i wanted to try and clarify something.

To make a new users with the most minimum information required can i just make one insert into the users table. *following the required columns for that table of course.

I did noticed when creating a new user as you suggested that 4 rows were inserted into the users_settings table.
affiliation
biography
gossip
signature
*I only filled in the required information on the create new user form so the information in these records is basically bank.

Are these actually required?

I think I've got all the foreign tables figured out as far as the information i want to insert. I'm just trying to make sure i don't overlook a required foreign table that will break things if user information is missing.

Thanks!
~Jonathan
jwtlake
 
Posts: 8
Joined: Mon Jul 29, 2013 8:58 am

Re: creating new users via DB insert

Postby asmecher » Fri Aug 09, 2013 12:49 pm

Hi Jonathan,

None of the insertions in user_settings are required -- just if you have the energy left for it.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: creating new users via DB insert

Postby cristianviza » Wed Sep 04, 2013 11:50 am

Hello.
I have a few user but now I want assig one with ROLE_ID_SITE_ADMIN . I need to assin of database directly. wich is the sql query?

Regards Cristian
cristianviza
 
Posts: 75
Joined: Tue Nov 06, 2012 10:22 am
Location: Argentina

Re: creating new users via DB insert

Postby asmecher » Wed Sep 04, 2013 12:53 pm

asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron