The issue
I am trying to hide certain pinned posts from appearing on the main forum page. The code below works, but it hides the post everywhere on the forum.
How can I adjust this so it only hides the pinned posts on the main /forum/ URL?
use Flarum\Extend;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
return [
(new Extend\ModelVisibility(Discussion::class))
->scopeAll(function (User $actor, Builder $query, string $ability) {
// This hides the IDs everywhere (index, tags, search, etc.)
$hiddenIds = [1, 42, 99]; // replace with your discussion IDs
$query->whereNotIn('id', $hiddenIds);
}),
];