Trouble with custom activity function
-
Hello,
I’m trying to modify the activity page for my users to show their partner’s activity. I have the working functionality but in converting a query into a function to reuse, it no longer works.
Working:
global $bp, $wpdb; $myid = $bp->loggedin_user->id; $ourlink = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = 'linkid' AND user_id = '$myid'"); $partnerid = $wpdb->get_var("SELECT user_id from $wpdb->usermeta where meta_key='linkid' AND meta_value = '$ourlink' AND user_id != '$myid'"); $partner = '&user_id=' . $partnerid; if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $partner ) ) :
Not Working (Undefined Variable Error on the activity loop)
Theme functions file:
function sw_partner_id() { global $bp, $wpdb; $myid = $bp->loggedin_user->id; $ourlink = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = 'linkid' AND user_id = '$myid'"); $partnerid = $wpdb->get_var("SELECT user_id from $wpdb->usermeta where meta_key='linkid' AND meta_value = '$ourlink' AND user_id != '$myid'"); $partner = '&user_id=' . $partnerid; return $partner; } add_action('sw_partner_activity', 'sw_partner_id');
Modified Loop Template:
do_action( 'sw_partner_activity' ); if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $partner ) ) : ?>
I’m sure I’m missing something here. I’ve tried firing the action in a number of default hooks as well as just calling the function without adding an action. I’ve tried passing $user_id to the function. Really at a loss for why the $partner variable isn’t getting passed from the function to the loop.
- The topic ‘Trouble with custom activity function’ is closed to new replies.