We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42415
    • 115 Posts
    I am looking for the simplest method to display user specific content in the front end after login.

    So far I have created register as members, forgot password, change password, view profile & edit profile all working using LogIn.

    Is it possible to create user specific content for each user once they are logged in?

    What I would like to do is have a members page with a member specific form that when submitted is stored in the database. It would be the same form for each member but with some kind of hook or tag to define who the member is, this would be used to display the same submitted data for the user.

    The data that has been submitted & stored in the db can only be displayed in the front end member page to the member who has submitted it.

    What would be the best method to achieve this?
    Are there any add ons that could deliver this type of functionality?

    I tried Bob's User Specific Page guide but couldn't get the newly created resources to open for the individual users, I'm kinda thinking/hoping there is a straightforward solution some kind soul could recommend?

    running MODX Revolution 2.3.3-pl (traditional) [ed. note: jimmyjazz last edited this post 8 years, 9 months ago.]
      • 3749
      • 24,544 Posts
      Do the pages show up for the members after you clear the cache?

      Does making a member a sudo user solve the problem? (If so, you don't have the permissions right.)

      Assuming that the page with the information is a resource created by the user (in NewsPublisher?), another approach is to forget about the permission system and just use the user's ID in the 'createdby' field of the resource.

      Then add a tag for this snippet in the template of the pages. It forwards the user to the Login page is it's not their own page:

      /* let admins see the page */
      if ($modx->user->isMember('Administrator')) {
        return '';
      }
      
      $loginId = 12; // Change to ID of Login page.
      
      /* Forward users to the login page if it's not their page */
      if ((int) $modx->resource->get('createdby') !== (int) $modx->user->get('id') ) {
          $modx->makeUrl($loginId, "", "", "full");
          $modx->sendRedirect($url);
      } 
      
      return '';



      Important! Make sure the snippet won't execute on the Login page!




        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 42415
        • 115 Posts
        Hi Bob,
        I just read your reply. Actually I already deleted all the User Specific Page resources, but, to answer your question about the Sudo user;
        Yes, if I made a member a Sudo user they could access the pages, so it looks like I got the permissions wrong then.

        Actually I decided on a different approach after reading the following forum (and yes you also gave invaluable contribution here also):

        http://forums.modx.com/thread/72130/different-landing-page-after-login-based-on-username

        Now I'm at the stage where I have created 4 users with 4 separate individually themed landing pages.

        The next part is adding the forms whereby upon submit, the users id is also recorded into the database so their data that has been submitted & stored in the db can only be displayed in the front end member page to the member who has submitted it.

        So I guess my question has adjusted to focus on this now.

        What would be the best method to achieve this?
        Are there any add ons that could deliver this type of functionality?

        I'm starting to read about the Formz add on, but I'm very open to any useful easy to implement suggestion.
          • 3749
          • 24,544 Posts
          It's difficult to say because there are so many different ways to do this.

          I can't think of any extras to do this, but that doesn't mean aren't any.

          One way would be to create a user group for each user, then set that group as the "primary user group" for the user (those two steps would be manual). You could then have a plugin attached to OnWebAuthentication, that redirected the user based on their primary_group field.

          It kind of depends on how many users you expect to have and the need to automate the process.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting