Skip to content

Giving admin/owner/viewer access to all sites (in bulk) #2658

Discussion options

You must be logged in to vote

👋 @Tony-MF

I'm not sure if there is an API endpoint for this, but you can probably do this by connecting to the running container (if you are using containers) and calling a few functions.

$ cd hosting
$ docker compose exec -ti plausible bin/plausible remote
iex> import Ecto.Query
iex> alias Plausible.{Site, Repo, Auth}

# this code is untested
iex> add_members = fn role, emails, sites ->
  Repo.transaction(fn ->
    sites = Site |> where([s], s.domain in ^sites) |> Repo.all()
    users = Auth.User |> where([u], u.email in ^emails) |> Repo.all()
    for site <- sites, user <- users do
      IO.puts("giving #{user.email} #{role} access in #{site.domain}")
      Repo.insert!(%Site.Membership{

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Tony-MF
Comment options

Answer selected by Tony-MF
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants