Weird double query using WPDB
-
Hey guys,
I’m running a query whenever someone logs in for the first time to sign them up to some groups automatically.Here is the code.
foreach($officialGroups as $groupSubscribe) :
$subscription = $wpdb->insert(‘wp_bp_groups_members’,
array(
‘group_id’ => $groupSubscribe, ‘user_id’ => 5, ‘inviter_id’ => 0,
‘is_admin’ => 0, ‘is_mod’ => 0, ‘user_title’ => ‘Member’,
‘date_modified’ => “$time”, ‘comments’ => ”,
‘is_confirmed’ => 1, ‘is_banned’ => 0, ‘invite_sent’ => 0),
array(
‘%d’, ‘%d’, ‘%d’,
‘%d’, ‘%d’, ‘%s’,
‘%s’, ‘%s’,
‘%d’, ‘%d’, ‘%d’));
if($subscription)
{
echo ‘Query ran
‘;
}endforeach;
It’s being problematic. The $officalGroups array is simply a list of group ids being passed over. There are 6 in total.
I’ve done an echo at each iteration of the loop and it confirms the query only runs once, however when I check the DB and consequently the front-end it’s subsribed te member to each group 3 times.
Any ideas why?
I’ve tried running 6 manual queries, flushing the last WPDB transaction and so on but nothing seems to work.
Thanks
- The topic ‘Weird double query using WPDB’ is closed to new replies.