Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Groups

Asked Modified Viewed 3,229 times
S
samson
S
samson 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

Hi, how can I do something that every new user you will be automatically add to the selected groups?

Thank you.
Edited by samson on 24-06-2010 16:38,
0 replies

9 posts

K
kneekoo
K
  • Senior Member, joined since
  • Contributed 289 posts on the community forums.
  • Started 12 threads in the forums
  • Answered 1 question
answered
Senior Member

Without modifying the core this could be done with an infusion. Here's the infusion's plan for developers with spare time on their hands:

1. Create an administration page to allow admins to select the desired groups to add the new members by default.
2. Create a panel that uses checkgroup() to test if a member is missing access from the default groups. The missing groups could be stored in an array.
3. If a member is missing from one or more groups, the access could be generated with a foreach() based on the previous array, then UPDATE DB_USERS SET user_groups='$new_groups' WHERE user_id='X'.

Here's the sample code for the panel:
if (iMEMBER) {
   $no_access = array();
   $default_groups = dbarray(dbquery("SELECT groups FROM ".DB_PREFIX."predefined_groups"));
   foreach (explode(".", substr($default_groups, 1)) as $group) {
      if (!checkgroup($group)) $no_access[] = $group;
   }
   if (!empty($no_access)) {
      $add_groups = "";
      foreach ($no_access as $group) {
         $add_groups .= "." . $group;
      }
      dbquery("UPDATE ".DB_USERS." SET user_groups='".$userdata['user_groups'].$add_groups."' WHERE user_id='".$userdata['user_id']."'");
   }
}


If you don't want to wait until someone makes this infusion, you can use the code above to create a panel for Members-only, but you will manually have to add the groups in the script AND make sure you don't make any mistake. Here's how it should look:

if (iMEMBER) {
   $no_access = array();
   $default_groups = ".1.2.6.9";
   foreach (explode(".", substr($default_groups, 1)) as $group) {
      if (!checkgroup($group)) $no_access[] = $group;
   }
   if (!empty($no_access)) {
      $add_groups = "";
      foreach ($no_access as $group) {
         $add_groups .= "." . $group;
      }
      dbquery("UPDATE ".DB_USERS." SET user_groups='".$userdata['user_groups'].$add_groups."' WHERE user_id='".$userdata['user_id']."'");
   }
}

As you can see, $default_groups doesn't have a query but a string containing the groups you want your members added to by default. Rules about $default_groups:

1. No spaces at all inside that string;
2. The string always begins with the period character "." because all groups must be proceeded by that character for data processing inside the script and the PHPFusion core itself.
0 replies
— 1 year later —
S
sebby
S
sebby 10
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
answered
Newbie

hi, im trying to create a code wich moves/adds all users automaticly from a group(or from no group) to another after they reach 10+ forum posts.The ideea is because im setting the forum permissions for development area of the forum so only members from certain groups can post there (the newbies can se but they can not post) Here is my code,i know something is wrong there but don`t know what:
$respost = dbquery("SELECT user_posts FROM ".DB_USERS." WHERE user_id='".$userdata['user_id']."'");
$datapost = dbarray($respost);
$group = ".+10_Posts_Members";
if ($datapost['user_posts'] <= 10) {$add_groups .= "." . $group;
      }
      dbquery("UPDATE ".DB_USERS." SET user_groups='".$userdata['user_groups'].$add_groups."' WHERE user_id='".$userdata['user_id']."'");
   }
}
0 replies
A
Ankur
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
answered
Veteran Member

You have everything in $userdata. Try this :

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
if ($userdata['user_groups'] >= 10)
{
// group ID, i.e the ID of group in which you want to add
$group_id = 1;
if (!preg_match("(^\.{$group_id}$|\.{$group_id}\.|\.{$group_id}$)", $userdata['user_groups'])) {
$user_groups = $userdata['user_groups'].".".$group_id;
$result2 = dbquery("UPDATE ".DB_USERS." SET user_groups='".$user_groups."' WHERE user_id='".$userdata['user_id']."'"wink;
}
}[/syntaxhighlighter]
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

I think you made a hiccup ankur. You do a condition that's checks if user groups is equal to or more than 10. should be checking post count. good job helping.
0 replies
S
sebby
S
sebby 10
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
answered
Newbie

10x for trying Ankur, i apreciate your effort but as i read your code i think the if condition is not correct as Mittens Returns says. If you have another ideea ..
I need the code to evaluate if a user has 10 or more forum posts and if users have 10+ to move them to another group automaticlly.
0 replies
A
Ankur
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
answered
Veteran Member

Oh LoL pfft

Sorry I think that I posted it in hurry... pfft Thanks Mittens smile

Ok it should be :
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]if ($userdata['user_posts'] >= 10)
{
// group ID, i.e the ID of group in which you want to add
$group_id = 1;
if (!preg_match("(^\.{$group_id}$|\.{$group_id}\.|\.{$group_id}$)", $userdata['user_groups'])) {
$user_groups = $userdata['user_groups'].".".$group_id;
$result2 = dbquery("UPDATE ".DB_USERS." SET user_groups='".$user_groups."' WHERE user_id='".$userdata['user_id']."'"wink;
}
}[/syntaxhighlighter]
0 replies
S
sebby
S
sebby 10
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
answered
Newbie

How you recomand me to insert the code? i would like to have it as an infusion so if i upgrade or change something i don`t loose this
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

you could save the code on your pc. then simply add it to includes/header_includes.php

you may want to add the code below before $userdata['user_post'] >= 10
iMEMBER && 

(may not need it)
0 replies
S
sebby
S
sebby 10
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
answered
Newbie

NOTE: This is reply to the CODE/MOD By Ankur (automaticly add users to certain group if they have 10 or more POSTS in forum)
EDIT: FEEL I`M GOING CRAZZY, EDITED THIS POST 99999TIMES
IF A USER WICH IS NOT GRANTED PERMISSIONS TO CERTAIN AREA OF THE FORUM TRIES TO QUICK REPLY HE CAN, BUT IF TRYES ADVANCED NO .. need a FIX so no one to be able to post if is not in the group that is allowed to POST
Error Log:
Error    Date    Status
topics/add_message.php
Undefined index: PF750 Line: 66    February 18 2012 13:23:52    
howtos.tk/profile.php
Undefined index: 423 Line: 426    February 18 2012 13:15:23    
howtos.tk/profile.php
Undefined index: 424 Line: 427    February 18 2012 13:15:23    
howtos.tk/profile.php
Undefined index: 420 Line: 421    February 18 2012 13:15:23    
howtos.tk/profile.php
Undefined index: 420 Line: 422    February 18 2012 13:15:23    
howtos.tk/profile.php
Undefined index: 421 Line: 424    February 18 2012 13:15:23    
howtos.tk/profile.php
include(locale/English/view_profile.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory Line: 418    February 18 2012 13:15:23    
templates/header.php
Undefined index: user_posts Line: 19    February 18 2012 12:46:58    
administration/forums.php
Undefined variable: forum_password Line: 128    February 18 2012 12:30:12    
howtos.tk/maincore.php
mysql_fetch_assoc() expects parameter 1 to be resource, boolean given Line: 233    February 17 2012 02:02:25    
site_map/site_map.php
Undefined index: SM148 Line: 165    February 17 2012 00:50:47    
templates/panels.php(74) : eval()'d code
Undefined index: fwl002 Line: 27    February 16 2012 21:05:36    
templates/panels.php(74) : eval()'d code
Undefined index: fwl001 Line: 16    February 16 2012 21:05:36    
administration/infusions.php
include(../infusions//infusion.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory Line: 188

EDIT: FIXED THE PROBLEM WICH WAS QUIK REPLY TO AJAX (SHOULD BE DISABLED)
Edited by sebby on 22-02-2012 18:39,
0 replies

Category Forum

User Administration - 8

Labels

None yet

Statistics

  • Views 0 views
  • Posts 9 posts
  • Votes 0 votes
  • Topic users 5 members

5 participants

K
K
  • Senior Member, joined since
  • Contributed 289 posts on the community forums.
  • Started 12 threads in the forums
  • Answered 1 question
S
S
samson 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
A
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
T
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
S
S
sebby 10
  • Newbie, joined since
  • Contributed 6 posts on the community forums.

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet