Keyword

Importing Users then assigning k2 groups

  • Nic Nowlan
  • Nic Nowlan's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #74454 by Nic Nowlan
Importing Users then assigning k2 groups was created by Nic Nowlan
Is there a good way to assign users to a group that have no k2 group association? I'm migrating a site from joomla 1.0, so I imported the old users and installed K2. I now have about 1000 users with no k2 group association but would like them to all go to a group I made. I'd rather not go through every user and assign them a group, it's rather time consuming and time is money!

Please Log in or Create an account to join the conversation.

  • Nic Nowlan
  • Nic Nowlan's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #74455 by Nic Nowlan
Replied by Nic Nowlan on topic Importing Users then assigning k2 groups
So the only method would be to go through 1000 users and flag each one to a k2 group? :(

Please Log in or Create an account to join the conversation.

  • Nic Nowlan
  • Nic Nowlan's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #74456 by Nic Nowlan
Replied by Nic Nowlan on topic Importing Users then assigning k2 groups
Could I go into the database and fill that field in with the k2 group I want everyone to be in, using a command? If it would change everyone to that group it would be okay, since only a few people are in the non-default k2 group.

Please Log in or Create an account to join the conversation.

More
15 years 1 month ago #74457 by Gobezu Sewu
Replied by Gobezu Sewu on topic Importing Users then assigning k2 groups
go to k2/user groups and on the most right column you will see the id of each group
find out which id the group you want to shuffle all your users into, and once you have it
fire up your db tool and execute the following query

make sure to replace X with the group id you just identified to be the default groups id

update jos_k2_users set group = X

Please Log in or Create an account to join the conversation.

  • Nic Nowlan
  • Nic Nowlan's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #74458 by Nic Nowlan
Replied by Nic Nowlan on topic Importing Users then assigning k2 groups
Thank you thank you thank you!

Gobezu Sewu said:go to k2/user groups and on the most right column you will see the id of each group find out which id the group you want to shuffle all your users into, and once you have it
fire up your db tool and execute the following query

make sure to replace X with the group id you just identified to be the default groups id

update jos_k2_users set group = X

Please Log in or Create an account to join the conversation.

  • Nic Nowlan
  • Nic Nowlan's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #74459 by Nic Nowlan
Replied by Nic Nowlan on topic Importing Users then assigning k2 groups
Well, that would work if K2 actually imported the users from jos_users before they were assigned to a k2 user group. When I checked the database jos_k2_users only had the users assigned to a k2 user group. Unfortunately it looks like I have to go through every user record, which makes me not want to convert our news site to k2. Thanks for your help!

Please Log in or Create an account to join the conversation.

More
15 years 1 month ago #74460 by Gobezu Sewu
Replied by Gobezu Sewu on topic Importing Users then assigning k2 groups
don't give up that easy

do this one instead which picks out only those not already defined in k2 as users and populates the k2 user table

make sure to replace X with the group id you identified to be the default groups id

INSERT INTO jos_k2_users (userID, userName, gender, description, group, plugins)
SELECT id, name, 'm', '', X, '' FROM jos_users WHERE id NOT IN (SELECT userID FROM jos_k2_users)

Please Log in or Create an account to join the conversation.

  • Nic Nowlan
  • Nic Nowlan's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #74461 by Nic Nowlan
Replied by Nic Nowlan on topic Importing Users then assigning k2 groups
Hmm , Im getting syntax errors in MySQL 4.1.22 - I'll have more time to look over the manual for that version of MySQL tomorrow. Thank you for all your help.

Gobezu Sewu said:don't give up that easy
do this one instead which picks out only those not already defined in k2 as users and populates the k2 user table

make sure to replace X with the group id you identified to be the default groups id

INSERT INTO jos_k2_users (userID, userName, gender, description, group, plugins)
SELECT id, name, 'm', '', X, '' FROM jos_users WHERE id NOT IN (SELECT userID FROM jos_k2_users)

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #74462 by Omar Ramos
Replied by Omar Ramos on topic Importing Users then assigning k2 groups
When I saw this entry yesterday I knew that there was a different way I would need to handle it for the site I'm about to try and build for our college (a Faculty website repository, with students allowed to login and make comments) after I realized that when I changed the parameter for K2 to only "allow registered users to comment" that a user in the frontend would not automatically be granted this right...they would need to be a part of the Registered K2 User Group first. Which would be a lot of manual labor as you guys have already talked about above.

While the mentioned SQL queries do assist a lot for existing users, they do not do much for future users.

Since my site is new, and since students would be authenticating with their student login info, I needed something that would auto-add a user to a group when they first logged in.

So what I did was edit the k2.php and k2.xml user plugin files in order to get the functionality I wanted.

First I needed to add a custom SQL parameter into the k2.xml so that I could pick the group I want to be auto-assigned, then in the k2.php file I added an additional if statement that checks for when a user is new and adds an entry into the #__k2_users table if they are with the chosen group assignment.
Attachments:

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #74463 by GreenDome
Replied by GreenDome on topic Importing Users then assigning k2 groups
Hi Omar,

I have similar issue where all my users have been imported from an external database and need to be set to K2 Registered Group. I have downloaded your plugin and changed the xml file to set default value to 6. I then installed the plugin which worked fine but when i log in as a user it doesn't change the group assignment to K2 Registered Group so cant post comments :(

Please could you advise what i may be doing wrong?

Many Thanks
GD

Omar Ramos said:When I saw this entry yesterday I knew that there was a different way I would need to handle it for the site I'm about to try and build for our college (a Faculty website repository, with students allowed to login and make comments) after I realized that when I changed the parameter for K2 to only "allow registered users to comment" that a user in the frontend would not automatically be granted this right...they would need to be a part of the Registered K2 User Group first. Which would be a lot of manual labor as you guys have already talked about above.
While the mentioned SQL queries do assist a lot for existing users, they do not do much for future users.

Since my site is new, and since students would be authenticating with their student login info, I needed something that would auto-add a user to a group when they first logged in.

So what I did was edit the k2.php and k2.xml user plugin files in order to get the functionality I wanted.

First I needed to add a custom SQL parameter into the k2.xml so that I could pick the group I want to be auto-assigned, then in the k2.php file I added an additional if statement that checks for when a user is new and adds an entry into the #__k2_users table if they are with the chosen group assignment.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum