I’m still not sure why I deleted support for the default and anon homepages before. I put those back.
Now if there is a custom_default_homepage it uses that unless there is a matching group match. If there’s an anon_page and the user is anonymous, it uses that.
I couldn’t figure out how or when the mobile page should be set (is it for anon users? all users? does it override the default page? the group map?), so I deleted it. If you’re using that mobile page, tell me what you think it should override (I think maybe set it as the default page if they are on mobile, but if there is a group page, then use that? Still not clear what to do for anon vs logged in–I guess there maybe needs to be mobile versions for all of them?).
Here’s the code:
let url = null;
if (settings.custom_default_homepage) {
url = settings.custom_default_homepage.replace(/^\/+/g, "");
}
if (user) {
if (user.primary_group_name && settings.group_page_map) {
let groupMap = settings.group_page_map.replace(",", ":").split("|");
const mapEntry = groupMap.find((value) =>
RegExp(user.primary_group_name).test(value)
);
if (mapEntry) {
url = mapEntry.split(":")[1].replace(/^\/+/g, "");
}
}
} else if (settings.anon_page) {
url = settings.anon_page.replace(/^\/+/g, "");
}
And then it changes the homepage only if url has a value.
Is this theme component intended to redirect anyone in the group to homepage on login or using the links? I have it installed, and the logo will direct to the selected page but on login the user still is directed to the default /latest page. If this handles that login redirect, I must still have something set incorrectly.
My goal is all users be included in a default group and all be redirected to an alternate page on login.
It needs to be their Primary group for this TC to kick in. That is by design, so that there is no conflict when a user is a member of more than one group with a redirect.
Our logic at the start was that it only overrides the default homepage - all others (including anon) take precedence.
The classic use case is using the Categories + Latest view on desktop, as this displays as Categories on mobile (which isn’t very useful).
These days, the sidebar makes this unnecessary for most instances, so I think that removing it makes sense. It might catch out some who have been using the TC for a while though.
Is trust level 0 considered a valid group? Would this be the correct setting for the Group Page Map? trust_level_0:/discourse-ai/ai-bot/conversations. That is the current setting I have set.
Have you tried to set the custom default homepage to your AI bot page (so it’s the default for everyone) and then set the homepage for anon users to latest (to overwrite the default for them)?
First, thank you everyone for jumping in and helping with this! It is greatly appreciated!
This is a head scratcher for me.
I have installed this plugin without any issues and set trust_level_0 in the settings with make this primary group. All members in site were added to the group. All users show this as the primary group now.
In the Custom Homepage for Groups component settings this is what I have set.
When accessing the page the users in the Community-Core primary group still land on /latest. If I change the Anon Page to something other than /latest when logging in the users will be shown whatever page is shown in that field so that is the redirect that is occurring.
I am using the Canvas Screen theme and changed to the default to test with the same result.
I also disabled all theme components and plugins to see if this helped without success.
I am thinking that there is either I am missing something that may be apparent to others or there may be an issue with the component.
When you right click on your site and select inspect you can see what pfaffman is asking for.
For example I see this on my user admin page (/admin/users/{user_id}/{username})
That is what I meant, but I now remember/see that the component gets the primary group from the user model, not from the CSS.
So, maybe find a user in the admin user route, and add .json to the URL. Then check what their primary group is and search (in the browser) for primary_group: true and check that the name matches exactly the case you used in the theme config.
The primary group name is indeed Community-Core, with the capital letters and hyphen, which is exactly what I have entered in the theme component’s settings.
No. If it’s going to the anon page and not the “custom default homepage”, then it’s not finding the user when it does
const user = api.getCurrentUser();
I don’t know how that could be happening if the user is, in fact, logged in.
Ah, it sets the user in the initializer, so I think if you log in after the site is loaded, this code may not execute again. Have you tried reloading the page?
Thanks Jay, I have tried reloading. I tried numerous adjustments to the urls and similar. It definitely loads the Anon page. If I change that it goes to that page and also shows /latest in the browser url.
I have search and assume there is no other way to simply redirect. It was easier with php sites. I still am novice with Discourse.