K2 Community

Join the network of the powerful content component for Joomla!

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!

Tags: groups, import, k2, user

Reply to This

Replies to This Discussion

So the only method would be to go through 1000 users and flag each one to a k2 group? :(

Reply to This

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.

Reply to This

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

Reply to This

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

Reply to This

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!

Reply to This

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)

Reply to This

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)

Reply to This

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:

Reply to This

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.

Reply to This

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.
Attachments:

Reply to This

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.

Reply to This

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.

Reply to This

Reply to This

RSS

Advertisement

Latest Activity

Matthew Santana added a discussion
Hello! I'm relatively new to web development and I have to admit that Joomla! and K2 have made it a rewarding experience. There are so many possibilities. That being said I hate to make my first post here about an error however it is getting in the…
52 seconds ago
Matthew Santana, Kibekas, Ninja B and 2 more joined K2 Community
5 minutes ago
Not sure how the rest would be affedcted but creating a table to join category ID's is pretty simple as far as database modeling goes ... That being said, I don't wan't to judge how and why it's the way it is, it simply is :-) Maybe the developpers…
5 minutes ago
Plz send a link if site is live
2 hours ago
See the k2 menu choices at the bottom - latest from user or categories select the category and set the number of items and it will work
2 hours ago
FidelGonzales added a discussion
I'm having some issues getting my categories to appear properly. The culprit seems to be the following code: . In default form, there is a huge gap on the top of the category page. After removing a few of these, the issue is partially fixed with cer…
2 hours ago
someone better that i may can tell you, try commenting the div class clr's our and see what happens
2 hours ago
Thanks for the reply. Unfortunately I'm not so experienced with Firebug nor CSS. I attached a new image, where one can see more information. Does this help a bit more?
2 hours ago
Whatever is done will modify the core, but will work. How about putting the category id's in a field like the xtra filelds and teach the core to parse them out. Its changing the way things work - not likely to happen unless a module like followeyes…
2 hours ago
I don't think the concept of the single-category per item content structure is a way of thinking that is advanced and, therefore, a reason to change the content construction strategy and our subsequent way of thinking. It is merely a huge limitation…
2 hours ago
2. if you are trying to remove a video from an item in the backend, click on the video tab scroll to the bottom and check delete currrent and save
2 hours ago
Please post a link if the site is live Use firebug to see what there and what needs to be changed
3 hours ago
Also, to skip the extra field you dont want edit in the override item.php and put something like {pseudocode} phpif this->extrafield->name="fieldyouwantto skip" else let the rest of the existing foreach loop run phpendif endfor something like that s…
3 hours ago
Kibekas added a discussion
There is a problem with excess of free space between 'itemListSubCategories' and 'itemList'. It seems to be derving from div class 'itemlistsubcategories' Please see the image attached. Does anyone know how to solve this problem? Via CSS?Thanks!
3 hours ago
you can get the extra fields like this if it suits your needs $custom = $this->item->extra_fields; and then addressing extra fields for the item like echo $custom[1]->value; depending on the position, 0, 1,2,3,4 etc in the array experiment with this…
3 hours ago
deton and Daito joined JoomlaWorks's group
For K2 translators
3 hours ago
I can translate to Russian
3 hours ago
I have a case right now where I would love to be able to set several categories for one article. For now, it has been solved with the use of tags, and I suspect this is how we will have to use it in the future. It might just be that we are used to…
3 hours ago
Viktoria (and Simon), Did you ever find out how to put one single extra field (not the whole bunch...) a different place than at the bottom of the article? This means we need to have a way to identify this particular field and add the code for it…
3 hours ago
Valentine added a discussion
Greetings to all . So here is what i cant understand1. i Cant login as an admin tru k2 login in frontend form just resets and i see begining of page2. I cant understand how to remove Related videos Any help will be good thanks in advance
4 hours ago

© 2010   Created by JoomlaWorks.

Badges  |  Report an Issue  |  Terms of Service