- Posts: 11
COMMUNITY FORUM
Importing Users then assigning k2 groups
- Nic Nowlan
-
Topic Author
- Offline
- New Member
Please Log in or Create an account to join the conversation.
- Nic Nowlan
-
Topic Author
- Offline
- New Member
- Posts: 11
Please Log in or Create an account to join the conversation.
- Nic Nowlan
-
Topic Author
- Offline
- New Member
- Posts: 11
Please Log in or Create an account to join the conversation.
- Gobezu Sewu
-
- Offline
- Senior Member
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
-
Topic Author
- Offline
- New Member
- Posts: 11
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
-
Topic Author
- Offline
- New Member
- Posts: 11
Please Log in or Create an account to join the conversation.
- Gobezu Sewu
-
- Offline
- Senior Member
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
-
Topic Author
- Offline
- New Member
- Posts: 11
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.
- Omar Ramos
-
- Offline
- Junior Member
- Posts: 30
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.
- GreenDome
-
- Offline
- Premium Member
- Posts: 93
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.
- Omar Ramos
-
- Offline
- Junior Member
- Posts: 30
I was going to say that you could follow the instructions that the previous posters made in order to change the group assignment for users that are already in your database, but then I just decided to add an onLoginUser event to the K2 User plugin.
What this event does is it checks the user after they have logged in to see if a K2 User Record already exists for the user or not. If there isn't one, then it will add them into the appropriate group. If they have one then it just continues on.
The way I made my initial changes meant that the group assignment would only work for NEW users, and not for existing ones, but now with this change it should work for both automatically, foregoing the need to open up phpMyAdmin and running the queries mentioned by the previous posters.
Please Log in or Create an account to join the conversation.
- GreenDome
-
- Offline
- Premium Member
- Posts: 93
I appreciate the updated version - thank you.
Just one small one question :) Do i need to change anything in the k2.php file to set my new default group?
Many Thanks
GD
Omar Ramos said:Hi GreenDome,
I was going to say that you could follow the instructions that the previous posters made in order to change the group assignment for users that are already in your database, but then I just decided to add an onLoginUser event to the K2 User plugin.
What this event does is it checks the user after they have logged in to see if a K2 User Record already exists for the user or not. If there isn't one, then it will add them into the appropriate group. If they have one then it just continues on.
The way I made my initial changes meant that the group assignment would only work for NEW users, and not for existing ones, but now with this change it should work for both automatically, foregoing the need to open up phpMyAdmin and running the queries mentioned by the previous posters.
Please Log in or Create an account to join the conversation.
- Omar Ramos
-
- Offline
- Junior Member
- Posts: 30
GreenDome said:Hi Omar,
I appreciate the updated version - thank you.
Just one small one question :) Do i need to change anything in the k2.php file to set my new default group?
Many Thanks
GD
Omar Ramos said:Hi GreenDome, I was going to say that you could follow the instructions that the previous posters made in order to change the group assignment for users that are already in your database, but then I just decided to add an onLoginUser event to the K2 User plugin.
What this event does is it checks the user after they have logged in to see if a K2 User Record already exists for the user or not. If there isn't one, then it will add them into the appropriate group. If they have one then it just continues on.
The way I made my initial changes meant that the group assignment would only work for NEW users, and not for existing ones, but now with this change it should work for both automatically, foregoing the need to open up phpMyAdmin and running the queries mentioned by the previous posters.
Please Log in or Create an account to join the conversation.
- GreenDome
-
- Offline
- Premium Member
- Posts: 93
GD
Omar Ramos said:Just open up the K2 user plugin within the Joomla backend so you can choose the group you want to use as the default...that should do the trick for setting the default group.
GreenDome said:Hi Omar, I appreciate the updated version - thank you.
Just one small one question :) Do i need to change anything in the k2.php file to set my new default group?
Many Thanks
GD
Omar Ramos said:Hi GreenDome, I was going to say that you could follow the instructions that the previous posters made in order to change the group assignment for users that are already in your database, but then I just decided to add an onLoginUser event to the K2 User plugin.
What this event does is it checks the user after they have logged in to see if a K2 User Record already exists for the user or not. If there isn't one, then it will add them into the appropriate group. If they have one then it just continues on.
The way I made my initial changes meant that the group assignment would only work for NEW users, and not for existing ones, but now with this change it should work for both automatically, foregoing the need to open up phpMyAdmin and running the queries mentioned by the previous posters.
Please Log in or Create an account to join the conversation.
- Dave Smith
-
- Offline
- New Member
- Posts: 12
Omar Ramos said:Hi GreenDome,
I was going to say that you could follow the instructions that the previous posters made in order to change the group assignment for users that are already in your database, but then I just decided to add an onLoginUser event to the K2 User plugin.
What this event does is it checks the user after they have logged in to see if a K2 User Record already exists for the user or not. If there isn't one, then it will add them into the appropriate group. If they have one then it just continues on.
The way I made my initial changes meant that the group assignment would only work for NEW users, and not for existing ones, but now with this change it should work for both automatically, foregoing the need to open up phpMyAdmin and running the queries mentioned by the previous posters.
Please Log in or Create an account to join the conversation.