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
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

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: 7737
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: 7737
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: 7737
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: 60
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: 7737
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