Search the Community
Showing results for tags 'arrayunset'.
-
I'm new to the site here, so I hope this is the right place for this post. It's also from a Wordpress site, but since Wordpress isn't the issue (and my [lack of] programming knowledge is), I figured this wouldn't fit on the Wordpress forums very well. So here's my problem. I downloaded a plugin which I'm trying to modify, and it's breaking my site (internal server error), which always makes for a fun day. Here's the piece I'm inserting: // ---START--- Add Buddypress 'Friends' filter. $wpdb->show_errors(); $k_user_id = $current_user->ID; $k_friends1 = $wpdb->get_col( "SELECT initiator_user_id FROM $wpdb->prefix . 'bp_friends' WHERE friends_user_id = $k_user_id AND is_confirmed = 1" ); $k_friends2 = $wpdb->get_col( "SELECT friends_user_id FROM $wpdb->prefix . 'bp_friends' WHERE initiator_user_id = $k_user_id AND is_confirmed = 1" ); $k_friends = array($k_friends1, $k_friends2); foreach($workers as $x) { if(!in_array($x, $k_friends, TRUE) { unset($workers[$x]); } } $wpdb->hide_errors(); The plugin has already defined the $workers variable, but I'd like to modify that variable by removing any values not contained in either of the two SQL queries. To provide more context, this plugin is an appointments plugin that I'm trying to integrate with Buddypress so that users can schedule appointments with each other, but only if they're friends. I know just enough php to get myself in trouble, so I'm sure there's something that's very obvious to everyone else, but I'm not seeing it...and it's very likely to do with me not understanding exactly how the functions are actually working. Any help would be very much appreciated. Thanks!
- 20 replies
-
- arrayunset
- in_array
-
(and 1 more)
Tagged with: