Skip Navigation

[Resolved] Access Control Post Group alternate template not working for translated content

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 16 replies, has 2 voices.

Last updated by brianD-14 1 year, 11 months ago.

Assisted by: Nigel.

Author
Posts
#2531295

I'm trying to configure an alternate template in an Access Control Post Group to redirect guests (not logged in) from the site home page to a custom welcome page. I'm following the documentation found here: https://toolset.com/course-lesson/restricting-access-to-pages/

My site is multilingual (English and Irish). I'm using WPML with the Classic Translation Editor. Therefore, there are two versions of the homepage:
Home: hidden link
Baile: hidden link

I initially created a single alternate content template called "Welcome Pages" configured with a Single Field block set to display the Post Content (Body) of hidden link, the translation of which is found at hidden link. The English homepage displays the Welcome page content as desired, but the Irish homepage (Baile) does not display the "Fáilte" content.

I've tried configuring this several different ways. I started with a single Access Control Post Group that included both the Home and Baile posts (pages). When that didn't work, I manually created a translation of the "Welcome Pages" template and set the Single Field block on that second template to display the Post Content of hidden link. That also didn't work. Finally, I created a separate Post Group for Baile that directly points to the Irish alternate template. That didn't work.

Is there a different way to do this, or some setting in either Access Control or WPML that I'm overlooking?

Go raibh maith agaibh! (Thanks)
Brian Doyle

#2531561

On a hunch, I reset my permalinks to "plain" and retested successfully. I then reset permalinks back to "post name" and now everything appears to be working. 🙂

#2531581

I spoke too soon! I had it working, but the problem came back. Note: I didn't make any change since the update posted above.

#2532075

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Brian

I set up something similar on my own local test site, and everything worked.

I have a static home page, with a translation to a second language.
I created a Content Template to display to guest users unable to see the home page, and I also translated that to the second language.
I created a Post Group within Access settings and added the home page (original language) to that group, and then updated the settings for that group so that guests were shown the content template (original language) instead of the page content.

I then tested it on the front end as a guest user, visiting the original language home page. It displayed the restricted content template content instead.

I used the language switcher to flip to the secondary language home page, and it showed the translated restricted content template.

In sum, I ensured there were translations of both the home page, and the restricted content template, and in the Access settings dealt only in the default language (the secondary language being handled automatically).

If that's the same as you tried then I think I would need access to your site to see if I can understand what's going on.

So let me set a private reply now in case it's needed.

You may want to create a temporary admin user for me to use that you can later delete, and be sure to have a current backup.

With a couple of kids in secondary school in Wicklow (one a DnD'er) that looks an interesting project. When do you think it will be ready to launch?

#2535283

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I can see the issue on your site, and it's not obvious at face value why it is behaving one way on your site that is different than how it behaves on my own test site.

So I'm taking a copy of the site to install locally where I can do some deeper debugging.

I'll get back to you later with my findings.

#2535613

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Brian

I'm going round in circles a little. I have it working fine on my local copy of your site, and there are a couple of times where I think I've identified why it does there but does not on your server, but when I apply the changes on your site it still doesn't work.

I'm working on a minimal version of your site locally, i.e. with all the non-essential plugins disabled.

Can I do the same on your server while working on this? Disable plugins other than Toolset and WPML?

#2535679

Thanks, Nigel. I'll do that asap (probably tonight, after my workday is complete) and get back to you.

#2535913
Screenshot 2023-01-16 8.25.19 PM.png
Screenshot 2023-01-16 8.21.38 PM.png
Screenshot 2023-01-16 8.11.45 PM.png

Hi Nigel! First off, apologies for misreading your earlier question, "can *I* disable plug-ins...." That would have been fine, but I thought you were asking me to do that. At any rate, I did disable all of the plug-ins down Toolset Access, Toolset Blocks, Toolset Types, and WPML Multilingual CMS. At one point, I had Toolset Blocks or Toolset Types disabled as well, but that actually disabled the English restricted-access template, so I turned it back on.

When I went back into to the restricted-content templates (to reactivate them), I noticed something odd about the translation ("Leathanaigh Fáilte") of the "Welcome Pages" template. First off, the English-language content was displaying in Gutenberg. Sure enough, when I inspected the settings of the Single Field block, the Post Source was pointing to the English "Welcome" page.

I don't remember the template showing those settings before. I have some thoughts as to what *may* have caused this, but first I want to capture for you the present state of the system in case you need to look deeper for diagnostic purposes. Please see the attached screenshots.

Next, I'm going to reactivate my back-up plugin and take a fresh backup of the site, as is.

#2535971
Screenshot 2023-01-16 9.57.13 PM.png

I reactivated UpdraftPlus Backup/Restore, saved a fresh backup to my Google Drive, and refreshed the Irish content template per the attached screen shot. I logged out and retested. This did not correct the error.

#2536003
Screenshot 2023-01-16 10.30.38 PM.png
Screenshot 2023-01-16 10.26.18 PM.png
Screenshot 2023-01-16 10.23.58 PM.png

A possible explanation occurred to me. I had previously installed and used a plugin called User Role Editor to reset and/or rename some of WP's default user roles, including Subscriber. I had been playing around with renaming the Guest role as well, but ultimately decided against that. However, in conjunction with WPML String Translator, I wonder if I broke some taxonomic relationship on the back end.

I reactivated both the User Role Editor and the WPML String Translator plug-ins. Note that the User Role Editor settings screen has a Tools tab that will reset the user roles. (See screen shot.)

In addition, I checked the Types_Access domain on WPML's String Translation screen and found matching 13 strings for user roles, none of which have Irish translations. This includes (or included) a string for "Guest," as well as some now-defunct "shop" roles that had been installed by another plugin. (WooCommerce, maybe?) Again, see the screen shot.

It occurred to me that the "Guest" string could be particularly problematic, so I deleted it. I then logged out and retested the restricted-access behavior on the front end. This did not correct the error. 🙁

At this point, I'm going to take a pause and let you weigh in. My next step would probably be to reset the user roles via that User Role Editor settings screen, but perhaps you have a better idea. If you agree, please feel free to go ahead and give that a try. I have a fairly full day tomorrow, but will try to check my personal email throughout the day if you have any other suggestions or questions.

Go raibh míle maith agat!
Brian

#2536143

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Sorry, the Irish Content Template linking to the Irish language post was part of the problem, and using WPML to translate the template (so that the same post ID—the English one—is referenced) was part of the solution on my local copy of your site. (Keep the whole chain of the set up in English and then WPML will automatically handle replacing the content with Irish where applicapable was the intention.)

So I had done that on your server, but it didn't resolve the problem.

I'll look again in a minimal install.

#2536217

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I've been deleting and recreating the templates, the Access post group, and nothing seems to work.

Except it works fine on my local copy.

Can you confirm you have a valid backup?

I would like to avoid the need to run remote debugging on your server, and so my hail mary is to export the database from my local copy and import it to your server (in case I stumbled across a solution locally that I have failed to replicate). I'm not very hopeful, given that I essentially started over setting it up on your server, but would like to try.

#2536331
Screenshot 2023-01-17 6.03.52 AM.png

Hi Nigel,

I just ran a full backup using UpdraftPlus and confirmed that the files are in my Google Drive. In case you need to confirm yourself, here's a link to the Drive folder containing those files:
hidden link

Thanks,
Brian

#2536481

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I imported the database from my working local copy to your server, where it's not working.

Sometimes with server-related issues it is fairly obvious what the issue might be, but the code in this case looks fairly straightforward and not obviously dependent on some PHP modules that could be missing.

I'll need to keep digging to see if I can get to the bottom of this, please bear with me.

#2536619

Thanks for sticking with it, Nigel. Quick question: Did you rule out running the custom role reset as a potential solution?