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
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)
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.
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.
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.
JoomlaPraise introduces Fresa, a new Joomla K2 Template with 8 themes to create a great looking sit…
© 2010 Created by JoomlaWorks.