file error: Deprecated: The each() function is deprecated

More
1 year 7 months ago #10966 by carsten888
Oh, I see.

on line 313:
//make clean array
		$groups_array = array();		
		for($n = 0; $n < count($groups); $n++){
			$row = each($groups);		
			$groups_array[] = $row['value'];			
		}
replace with
//make clean array		
		foreach($groups as $k => $v){			
			$groups_array[] = $v;
		}

will make a new update this morning.

Please Log in or Create an account to join the conversation.

More
1 year 7 months ago #10967 by carsten888
just released this in an update.

Please Log in or Create an account to join the conversation.

More
1 year 7 months ago #10968 by giles_taylor
Replied by giles_taylor on topic error: Deprecated: The each() function is deprecated
I've downloaded the new version but I receive this url when I click the link:
<br%20/>

Please Log in or Create an account to join the conversation.

More
1 year 7 months ago - 1 year 7 months ago #10969 by carsten888
are you sure you got
if($user_id){


}
around the code?

and your version is 1.1.3?
Last edit: 1 year 7 months ago by carsten888.

Please Log in or Create an account to join the conversation.

More
1 year 7 months ago - 1 year 7 months ago #10971 by giles_taylor
Replied by giles_taylor on topic error: Deprecated: The each() function is deprecated
Yes version 1.1.3

Here's the code:

if($user_id){

if($group==10){
$message = 'welcome client';
$message_type = 'info';
$redirect_url = $current_url;
}else if($group==11){
$message = 'welcome client 2';
$message_type = 'info';
$redirect_url = $current_url;

}

}
Last edit: 1 year 7 months ago by giles_taylor. Reason: Client names appeared in code

Please Log in or Create an account to join the conversation.

More
1 year 7 months ago #10979 by carsten888
$group is not defined.

this will work only if you are absolutely sure the user is assigned to only 1 group:
if($user_id){
$group = $usergroups[0];



if($group==10){
$message = 'welcome client';
$message_type = 'info';
$redirect_url = $current_url;
}else if($group==11){
$message = 'welcome client 2';
$message_type = 'info';
$redirect_url = $current_url;

}

}

Thsi code will work also when a user is assigned to more then one usergroup
(so this is the saver option in case in a few years some admin adds users to groups when this is long forgotten about)
if($user_id){

if (in_array('10', $usergroups)){
$message = 'Thanks for logging in client name';
$message_type = 'info';
$redirect_menuitem_id = 152;
}

if (in_array('11', $usergroups)){
$message = 'Thanks for logging in client name';
$message_type = 'info';
$redirect_menuitem_id = 140;
}

}
In the above example, the code for group 11 overrides the code for group 10. So by changing the order of the codes, you can set which group-redirect would be used when a user is assigned to both groups.

Please Log in or Create an account to join the conversation.

Time to create page: 0.192 seconds
Powered by Kunena Forum
 
spicy-sacerdotal