• Resolved tsumeone

    (@tsumeone)


    Hi,

    I don’t know actually if the issue is with buddypress 2.3.0 rc1 or with another plugin (I know BSALA plugin is not the cause of the problem), but I notice an issue: When someone removes a favorite, it removes ALL of the double quotes (“) from the bp_favorite_activities line in the database! It seems not to affect the regular favorite button (still shows which is favorite and which isnt) but caused a big problem with the plugin, since it only searches for the number in quotes. I have made a modification in case anyone else experiences the issue:

    Change this line:
    $query = "SELECT user_id FROM ".$wpdb->base_prefix."usermeta WHERE meta_key = 'bp_favorite_activities' AND meta_value LIKE '%:\"$activity_id\";%' ";

    To this:
    $query = "SELECT user_id FROM ".$wpdb->base_prefix."usermeta WHERE meta_key = 'bp_favorite_activities' AND (meta_value LIKE '%:$activity_id;%' OR meta_value LIKE '%:\"$activity_id\";%') ";

    I don’t know if this is actually a good solution or not (I don’t know PHP) but it seems to work for me so far.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tsumeone

    (@tsumeone)

    Actually that one would return favorites on some things that I did not actually favorite.

    I have done it in a more accurate (and very ugly way) here. Feel free to improve on this…

    $activity_id = bp_get_activity_id();
        global $wpdb;
        $query = "SELECT user_id FROM ".$wpdb->base_prefix."usermeta WHERE meta_key = 'bp_favorite_activities' ";
        $users = $wpdb->get_results($query,ARRAY_A);
        $users2 = array();
        foreach ($users as $user2)
        {
    	$favarray = bp_activity_get_user_favorites ( $user2['user_id'] );
            if(is_array($favarray)) {
    		if (in_array($activity_id, $favarray)) {
    			$users2[] = $user2;
    		}
    	}
        }
        foreach ($users2 as $user)
        {
    Plugin Author mahdiar

    (@mahdiar)

    hi
    Thank you very much for your help
    But I didn’t find any issue with bp 2.3
    Everything works perfect

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘issue with bp 2.30 rc1’ is closed to new replies.