We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22099
    • 11 Posts
    I’m having severe problems with caching. I’m using WebLoginPE to display user profiles, but when a user creates an account, they can’t see their profile before I open their page in the manager or clear the cache. I probably should mention that I’m using a custom plugin to create user folders where the WebLoginPE call is.

    The folder creation and subpage for profile editing plugin (Thanks to Dimmy!):
    if($mode=="new") {   
        $wuid = '-'.$user['internalKey'];
        $table_name = $modx->getFullTableName( 'site_content' );
        $fields = array(
            'type'    =>  'document',
            'contentType' => 'text/html',
            'content' => '',
            'pagetitle'   => $_POST['venue_name'],
            'longtitle'   => '',
            'alias'       => md5($_POST['username']),
            'published'   => '1', //is the page published?
            'parent'      => '83', //what is the parent of this new page?
            'isfolder'    => '1', // lets make this a folder
            'template'    => '8', //type template id here, you may need to check your database for the correct ID
            'cacheable'   => '0',
            'createdby'   => $wuid, 
            'createdon'   => time(),
            'editedon'    => time(),
            'publishedon' => time(),
            'hidemenu'    => '1'
        );
        
        $modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
        
        //Create  placeholder and put the id in a session to use for mail or whatever.
        
        $_SESSION['eigenpaginaid'] =  $modx->db->getInsertId();
        $modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
        $parent= $modx->db->getInsertId();
        $settings_table = $modx->getFullTableName( 'web_user_settings' ); //set the table to use
        $fields2 = array('webuser' =>  $user['internalKey'],'setting_name' => 'login_home','setting_value' => $parent); //set the parameters to insert
        $modx->db->insert( $fields2, $settings_table); // insert the parameters in the right table.
        
        //This will create a document in the above parent folder.
        
        //start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
        
        $fields = array(        
            'type'    =>  'document',
            'contentType' => 'text/html',
            'content' => '[[WebLoginPE? &type=`profile` &profileTpl=`userProfileEditTpl`]]',
            'richtext' => '0',
            'pagetitle'   => $_POST['venue_name'],
            'longtitle'   => '',
            'published'   => '1', //is the page published?
            'alias'       => md5($_POST['username']),
            'parent'      => $parent, //here we go create a doc in the first doc
            'isfolder'    => '0',
            'template'    => '11', //type template id here, you may need to check your database for the correct ID
            'cacheable'   => '0',
            'createdby'   => $wuid,
            'createdon'   => time(),
            'editedon'    => time(),
            'publishedon' => time(),
            'hidemenu'    => '1'          
        );
        
        $modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
        
        //end of page creation
        return;
        
    }
    


    And here is the WebLoginPE call from the folder which displays the user profile:

    [[WebLoginPE? &type=`users` &viewProfileTpl=`userProfile` &profileTpl=`userProfileEditTpl` &profileHomeID=`[[GetProfileChild]] ` &customTable=`users_custom_fields`]]
    


    Anyone got any ideas? Do I have to run a clear cache snippet after the folder creation?

    Olaf
      • 22099
      • 11 Posts
      Fixed it myself by running the clear cache function mentioned in the wiki, not the API one.