add user to blog, specified blog_id ignored
-
Hi, try to do something fairly simple here but I get a ‘strange’ behavior (that may be strange because I lack some insights)
add_user_to_blog(4,100,’author’);
works as expected : it add’s user 100 to blog 4 as author.
But in my script I do a query on the database (invitation matching) and after the $wpdb->get_results($query), myself nor the wp functions cannot change to the specified blog (switch_to_blog), so the attempt is made on the last known blog_id. When I do the same instruction as above after that db query, it cannot do it for the specified blog, so it uses the ‘last/current’ blog_id known (eg. 1)
I can change ‘that’ blog_id after the get_results statement with $wpdb->set_blog_id(the specified blog_id) and than it works fine, but I guess the wp(mu) functions like to handle switching to and back themselves (I can handle it on my own, but it’s the first and last thing the add_user function does, so it shouldn’t ‘do nothing’).So my question is : why seems blog_id ‘fixed’ after the query and do I have to do some ‘release’ on $wpdb after the query and before adding the user to the specified blog ? Or is it better practive to use set_blog_id myself. I don’t think it’s that big a deal for my script what the current blog_id is anyway.
- The topic ‘add user to blog, specified blog_id ignored’ is closed to new replies.