Issues when adding users to group with group_user_add

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
tlagren
Registered User
Posts: 2
Joined: Tue Jan 08, 2019 10:54 pm

Issues when adding users to group with group_user_add

Post by tlagren » Tue Jan 08, 2019 11:06 pm

Hi, I have some users in my phpBB setup already and now trying to update their group membership with some php code.

I'm using the group_user_add function as below

Code: Select all

$result = group_user_add($group_id, array($user_id), array($username));
The function returns an empty result which is good, and if I manually look in the DB table user_group a new post are added according to my command above so everything seems to be working correctly. The problem is that the group membership has no effect and are not visible in ACP. If I in ACP review the users groups, the group I just added isn't there.

I'm pretty sure I was using the exact same code with phpBB 3.2.3 earlier, but running 3.2.5 now.

Could my issues be related to a bug or changed features in releases between 3.2.3 and 3.2.5 or do you have any other ideas what's happening here?

PS. If I run my script again I got the message GROUP_USERS_EXIST which is because the user and group is already are added into the DB..

/Tomas
Last edited by kinerity on Tue Jan 08, 2019 11:17 pm, edited 1 time in total.
Reason: Moved to phpBB Custom Coding

tlagren
Registered User
Posts: 2
Joined: Tue Jan 08, 2019 10:54 pm

Re: Issues when adding users to group with group_user_add

Post by tlagren » Wed Jan 09, 2019 9:42 pm

I found the root cause to this and there is no problem with phpBB, it was me :-)
I have a function that fetch the ID for a group and then use that ID in the group_user_add function, but I had a bug in my script that cutted the first char of the group id returned by my function. I would normally found this very quick, but when removing the first digit from the group ID of my test group was unfortunately the exact same group id as the Registered users :-)

/Tomas

User avatar
AmigoJack
Registered User
Posts: 5588
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Issues when adding users to group with group_user_add

Post by AmigoJack » Thu Jan 10, 2019 8:29 am

tlagren wrote:
Wed Jan 09, 2019 9:42 pm
the exact same group id as the Registered users
That still should have brought you a GROUP_USERS_EXIST result, as every user is in that group already.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
canonknipser
Registered User
Posts: 1995
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Issues when adding users to group with group_user_add

Post by canonknipser » Thu Jan 10, 2019 12:56 pm

tlagren wrote:
Wed Jan 09, 2019 9:42 pm
I had a bug in my script that cutted the first char of the group id returned by my function
Sounds to me like a datatype problem - you maybe fetch the group id as a string, but it is a integer (numeric) data type. You should always respect the correct data types ;)
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

Post Reply

Return to “phpBB Custom Coding”