How can I choose my own group names?
-
How can I choose my own group names (instead of Group1, Group2, etc)?
If these are unchangeable, perhaps we can avoid displaying Group1, Group2, etc … and instead only display the group descriptions … ie, use the fixed group names only internally.
Also, is there a way to import a group list ?
Thank you in advance for responding … and I am not shy of going to code, if I have to.
thanks
-
This topic was modified 4 years, 11 months ago by
laymonk.
-
This topic was modified 4 years, 11 months ago by
-
the group numbers and indeed names are only used for admin. I am not planning to remove the numbers, many sites have lots of groups, and finding them quickly is important. Sorry.
I haven’t thought about export/import – in fact no-one has ever asked about this. The group names are stored in the options table.
Thank you very much for responding, and for the explanation.
One other question (I can create a new support thread, if you prefer):
Are there any hooks available?
for instance, upon initial sign-up, to automatically make a user a member of some groups, based on user-meta fields
thanks
-
This reply was modified 4 years, 11 months ago by
laymonk.
Are you happy coding? if so, then I can probably find functions or hooks
Yes, that’s the idea … I don’t mind coding this. That would really be most useful for me. Thank you.
this should get you close to what you want – not fully debugged or tested, so you might need to play with it
in essence in the user meta ‘private_group’ is set to the groups as a string with ‘*’ as delimiter eg
*group6*group8*group36*group39*group102*group103*group38*
so
//add assign group to register, add_action ('bbp_user_register', 'rew_add_group') ; //and to wp-login add_action('wp_login', 'rew_add_group_login', 10, 2); //and on every visit add_action('init', 'rew_add_group_on_init'); function rew_add_group ($user_id) { if ($user_id == 0) return ; // bail if no user ID rew_set_group ($user_id) ; } function rew_add_group_login($user_login, $user) { $user_id = $user->ID ; rew_set_group ($user_id) ; } function rew_add_group_on_init () { $user = wp_get_current_user(); $user_id = $user->ID ; rew_set_group ($user_id) ; } function rew_set_group ($user_id) { $check = get_user_meta ($user_id , 'some_parameter' , true ) ; if ($check == 'hello') { $newgroup = 'group38' ; } else return ; $group_string=get_user_meta( $user_id, 'private_group',true); $group_string = rtrim($group_string, '*'); $group_list = explode ('*' , $group_string) ; //if exists, then dont need to add if (in_array ( $newgroup, $group_list)) { return ; } else { $group_list[] = $newgroup ; $new_list = implode ('*' , $group_list).'*' ; update_user_meta( $user_id, 'private_group', $new_list); }This is really insightful, thanks a million.
I see how user_meta can be selected and acted upon.
I redirect wp_login to a custom login, will that affect the line:
> add_action(‘wp_login’, ‘rew_add_group_login’, 10, 2);Also, using the groupN field is problematic for me because the association between the user-meta values will be with the group descriptions, not their less meaningful id’s.
So, question for me is:
Is there a way to access the group descriptions and use that for matching to user-meta?what custom login are you using? chances are that it also hooks to that link, so the easiest way is just to test it to see that it works.
this code should work for a name (untested!)
function rew_set_group ($user_id) { $newgroupname = get_user_meta ($user_id , 'some_parameter' , true ) ; //quit if empty if (empty ($newgroupname)) return ; global $rpg_groups ; foreach ( $rpg_groups as $group => $name ) { if ($name == $newgroupname) { $newgroup = $group ; continue ; } } //quit if the name does not have a group if (empty ($newgroup)) return ; $group_string=get_user_meta( $user_id, 'private_group',true); $group_string = rtrim($group_string, '*'); $group_list = explode ('*' , $group_string) ; //if exists, then dont need to add if (in_array ( $newgroup, $group_list)) { return ; } else { $group_list[] = $newgroup ; $new_list = implode ('*' , $group_list).'*' ; update_user_meta( $user_id, 'private_group', $new_list); }-
This reply was modified 4 years, 11 months ago by
Robin W.
Hi,
Sorry I have not come back here on this topic. I got dragged into other things and have not looked at it more.
I was also put off by realising that there were already quite a few users in the system, and making the groups work was going to involve a ton of manual work:
- First to associate the private groups 1-by-1 to almost a hundred groups. YIKES!
- Then to associate each user of more than a hundred users to one or more private groups. YIKES!
The ‘User Management’ section is a nice feature, but only filters by private group’s groups (the roles filter doesn’t really work, and wouldn’t have been that useful anyways … not as much as other user meta fields that mirror the private groups’ names), and that didn’t help me at all in the end.
In the end, I began to doubt this is a practical solution for my use case. Without a way to manually or easily map forum groups to private groups, and users to private groups, I just don’t see it as a solution.
I also peered at the DB to see if I could figure out a pattern, so I could address it with sql or php, but because it doesn’t have it’s own custom tables I knew it was going to be more work and time than I was willing to give it.
-
This reply was modified 4 years, 11 months ago by
The topic ‘How can I choose my own group names?’ is closed to new replies.