At around line 161, replace: $sql = "SELECT`post_name` FROM {$wpdb->prefix}posts WHERE `post_parent` = {$bp->groups->current_group->extras['gpage_id']} AND `post_type` = '{$this->page_slug}' ORDER BY `menu_order` ASC LIMIT 1"; $bp->action_variables[0] = $wpdb->get_var($wpdb->prepare($sql)); with: $sql = "SELECT`post_name` FROM {$wpdb->prefix}posts WHERE `post_parent` = %d AND `post_type` = '%s' ORDER BY `menu_order` ASC LIMIT 1"; $bp->action_variables[0] = $wpdb->get_var($wpdb->prepare($sql, $bp->groups->current_group->extras['gpage_id'], $this->page_slug)); And around line 188, replace: $sql = "SELECT * FROM {$wpdb->prefix}posts WHERE`post_name`= '{$bp->action_variables[0]}' and`post_type`= '{$this->page_slug}' and`post_parent` = $gpage_id"; $page = $wpdb->get_row($wpdb->prepare($sql)); with: $sql = "SELECT * FROM {$wpdb->prefix}posts WHERE`post_name`= '%s' and`post_type`= '%s' and`post_parent` = %d"; $page = $wpdb->get_row($wpdb->prepare($sql, $bp->action_variables[0], $this->page_slug, $gpage_id));