[3.2.0]group_user_del function question

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
Chabniest
Registered User
Posts: 9
Joined: Sun Apr 30, 2017 10:01 pm

[3.2.0]group_user_del function question

Post by Chabniest » Wed Sep 13, 2017 2:12 pm

Hi @ all,

I have a little problem with this mentioned function.

Once in a week our members are checked if they are still in the correct group.

If they are not in the correct group they were removed from the individuell group and the default group must set to "registered users".

And there is the problem.

I receive the following error when I start the script:

PHP Fatal error: Call to a member function sql_in_set() on null in...../includes/functions_user.php on line 2814

The variable "$forum_group_name" ist the name of the individuell group where the member must remove from.

My code looks like so:

Code: Select all

group_user_del($forum_groupid, $forum_userid, $forum_username, $forum_group_name, true);
I ask also in the german support forum (phpbb.de) but it seems that nobody can help me in this case.

Has anybody an idea what I make wrong?

Thanks

Chabniest

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

Re: [3.2.0]group_user_del function question

Post by AmigoJack » Thu Sep 14, 2017 9:28 am

Chabniest wrote:
Wed Sep 13, 2017 2:12 pm
the script
That's the cause.
The worst thing about censorship is ███████████

Chabniest
Registered User
Posts: 9
Joined: Sun Apr 30, 2017 10:01 pm

Re: [3.2.0]group_user_del function question

Post by Chabniest » Fri Sep 15, 2017 7:25 am

AmigoJack wrote:
Thu Sep 14, 2017 9:28 am
Chabniest wrote:
Wed Sep 13, 2017 2:12 pm
the script
That's the cause.
4860 posts and now this post which helps nothing. No words.

Has anybody else an idea?

Thx

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 20360
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: [3.2.0]group_user_del function question

Post by RMcGirr83 » Fri Sep 15, 2017 9:17 am

His point was it is the script that you made that is causing the issue. You should probably post the entire script instead of snippets of it.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

User avatar
Ger
Registered User
Posts: 1088
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2.0]group_user_del function question

Post by Ger » Fri Sep 15, 2017 9:23 am

The error indicates that $db is not an object. That could be the case if you just bluntly include the functions_user.php without anything else.

However, as indicated by AmigoJack, we can't help you much more without you sharing more code.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

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

Re: [3.2.0]group_user_del function question

Post by canonknipser » Fri Sep 15, 2017 10:35 am

Chabniest wrote:
Wed Sep 13, 2017 2:12 pm
I ask also in the german support forum (phpbb.de)
I can't find any related topic or post of yours over there. But, as said, we need the code to help you. Just some out-of-sequence fragments are not enough
Greetings
Frank
phpbb.de support team member
English is not my native language
New arrival - Extensions and scripts for phpBB
no support via PM or mail

Chabniest
Registered User
Posts: 9
Joined: Sun Apr 30, 2017 10:01 pm

Re: [3.2.0]group_user_del function question

Post by Chabniest » Fri Sep 15, 2017 11:37 am

Hi guys,

here is the code of the script:

Code: Select all

include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

$foren_user_id=mysqli_query($con,"SELECT user_id, group_id, username  FROM `phpbb_users` WHERE user_id >= 48") or die(mysql_error());
while ($foren_user=mysqli_fetch_array($foren_user_id,MYSQLI_ASSOC))
{
 $forum_userid = $foren_user['user_id'];
 $forum_groupid = $foren_user['group_id'];
 $forum_username = $foren_user['username'];
 
 group_user_del($forum_groupid, $forum_userid, $forum_username, true, true);
}
And here is the Link to the original functions_user.php

There is still a "If" statement that specify when the user will removed from group.

The Users are in two groups. In the "registered Users" and an individuell group. The individuell group is set as default group. the member must remove from individuell group and the "registered users" group must be set as default.

Thx

Chabniest

User avatar
Ger
Registered User
Posts: 1088
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2.0]group_user_del function question

Post by Ger » Fri Sep 15, 2017 11:43 am

You miss quite some stuff. You simply cannot add only the includes/functions_user.php and expect things to work. You also need the DB object setup, the config, etc.
Usually you start an external script like:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

Chabniest
Registered User
Posts: 9
Joined: Sun Apr 30, 2017 10:01 pm

Re: [3.2.0]group_user_del function question

Post by Chabniest » Fri Sep 15, 2017 1:05 pm

Ger wrote:
Fri Sep 15, 2017 11:43 am
You miss quite some stuff. You simply cannot add only the includes/functions_user.php and expect things to work. You also need the DB object setup, the config, etc.
Usually you start an external script like:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
That code is allready inside. The specific error will never appear when this code were not inside.

Thx

Chab

User avatar
Ger
Registered User
Posts: 1088
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2.0]group_user_del function question

Post by Ger » Fri Sep 15, 2017 1:13 pm

Than, by all means, share your complete code instead of arbitrary snippets.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

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

Re: [3.2.0]group_user_del function question

Post by canonknipser » Fri Sep 15, 2017 1:16 pm

Chabniest wrote:
Fri Sep 15, 2017 1:05 pm
That code is allready inside.
But it doesn't show up in your code posted here:
Chabniest wrote:
Fri Sep 15, 2017 11:37 am
here is the code of the script
So, that is again only "half of the truth".

It's hard to help if you put only parts of code.

Some additional questions:
Why don't you use phpBB's database engine, but your own code without any error handling? mysqli_query(
mysqli_fetch_array

And if you look at the definitions of the parameters, you need to pass some of them as arrays, not as scalar values as you do:
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $log_action = true) (suffix _ary gives hint for an array)

Edit: and you don't give the group name, but only a true, that's the reason for your sql_in_set error. False means "no group name given"
Greetings
Frank
phpbb.de support team member
English is not my native language
New arrival - Extensions and scripts for phpBB
no support via PM or mail

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

Re: [3.2.0]group_user_del function question

Post by AmigoJack » Thu Sep 28, 2017 1:37 pm

Chabniest wrote:
Fri Sep 15, 2017 7:25 am
4860 posts and now this post which helps nothing
14 days later and you still haven't attached your full script.
The worst thing about censorship is ███████████

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 4 guests

cron