Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7661429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:35:50+00:00 2026-05-31T13:35:50+00:00

I’m using modX Revo with plugins Login and Babel . As there was wrote

  • 0

I’m using modX Revo with plugins Login and Babel. As there was wrote at Babel manual I made 2 contexts for two languages, used TV params and wrote contextSwitch plugin. It is mostly like plugin from example at the manual. After that I put plugin on event HandleRequest.

Everything is working except switching context after login: if user is authorized, modX shows only main page, the others show 404 page. I tried to rummage in the code and found out that method switchContext of model modx (line 1843 of /core/model/modx/modx.class.php) returns false.

  public function switchContext($contextKey, $reload = false) {
        $switched= false;
        if ($this->context->key != $contextKey) {
            $switched= $this->_initContext($contextKey, $reload); // RETURNS FALSE
            if ($switched) {
                if (is_array($this->config)) {
                    $this->setPlaceholders($this->config, '+');
                }
            }
        }
        return $switched;
    }

It happens, because context can’t be initiated (method _initContext of the same class at the same file). Here context is correctly creating, when we ask to switch to it, but $this->context->checkPolicy(‘load’) returns false (near 2169 line of the same file).

protected function _initContext($contextKey, $regenerate = false) {
    // HERE IS EVERYTHING ALLRIGHT
    $initialized= false;
    $oldContext = is_object($this->context) ? $this->context->get('key') : '';
    if (isset($this->contexts[$contextKey])) {
        $this->context= & $this->contexts[$contextKey];
    } else {
        $this->context= $this->newObject('modContext');
        $this->context->_fields['key']= $contextKey;
    }
    if ($this->context) { //HERE TRUE
        if (!$this->context->prepare((boolean) $regenerate)) { // HERE TRUE
            $this->log(modX::LOG_LEVEL_ERROR, 'Could not prepare context: ' . $contextKey);
        } else {
            if ($this->context->checkPolicy('load')) { // HERE FALSE - MODX CAN'T DO IT
                // .. SOME OTHER modX CODE

So after that I stopped to rummage at the core. May be somebody already saw something like that or know modx Revo core good to answer why modx can’t switch context when user is logged in?

P.s. I tried to use another event for context switch plugin – but of course this event is the most correct for the plugin. And I’m accenting that modx can’t switch context only while user is logged in!

UPDATE

I tried to edit some permissions. But nothing has happend (I cleared cash and relogged all users). Here is screeshot of context permissions (sorry for nonEnglish, however it should be clear):
enter image description here

UPDATE 2
Permissions were wrong: they have to be all 9999 and “list, veiw, load”. But the same time I can’t log in while i’m at second context as before I couldn’t. Now I tried to find out is it the same problem or not.

UPDATE 3
The second problem with login is solvineg very easy: in snippet params there should be &contexts=web,eng

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:35:51+00:00Added an answer on May 31, 2026 at 1:35 pm

    but $this->context->checkPolicy(‘load’) returns false (near 2169 line of the same file).

    Well, there’s your answer! The user needs at least “load” permission for the context in order to switch to it.

    Go to Security > Access Policies > right click the user group and choose to update it. In the Context Access tab make sure all front-end facing contexts are listed there with preferably the “Load, List & View” access policy. May want to do that for the Administrator user group first to prevent getting locked out of it yourself, as well as the (anonymous) group which is used for not logged in users.

    I think, though not 100% sure without seeing more about your specific setup, you didn’t gave the user group access to the second context which would explain why it does work for anonymous users.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.