On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • hi all, notably Bob & Susan ;-)

    i've spent a long time searching & haven't found the answer to this; so if i missed it, please feel free to link me to it.

    i'm trying to figure out how to get BOTH the Activation Emails...
    Register & ForgotPassword
    ...to accept/fill-in the users "fullname" (which IS required during initial Registration, so everyone has one), in the emails body greeting.

    it currently DOES use successfully... [[+username]]
    but i can't get it to work with... [[+fullname]], or [[+register.fullname]], or [[+login.fullname]], or [[+profile.fullname]], or [[+user.fullname]], etc etc. all it does is show that actual code(?).

    to be honest, i've got this whole thing up'n'running after a long period of learnings'n'research, and i STILL don't quite understand where "placeholders" come from, how they're figured out or created. but that's not necessarily what i'm needing from this post ;-)

    i would like to try & avoid modifying the original/core/snippets/plugins/code, but i'm not opposed to creating a new snippet if that's what's needed.

    REF: using ModX Revo 2.4.3 & Login 1.9.2

    This question has been answered by multiple community members. See the first response.

    [ed. note: syberknight last edited this post 3 years, 8 months ago.]
    • (bump)
      • discuss.answer
        As you probably noticed, the Login code is a little challenging to follow. wink

        The problem is that the user doesn't exist when the page is processed, so the code only has the entered username to work with.

        The only thing I can think of to try (and I don't have much confidence in it) is a pre- or post- hook that does this:

        $usernameField = $this->modx->getOption('usernameField', $scriptProperties, 'username');
        $username = $hook->getValue($usernameField);
        $user = $modx->getObject('modUser', array('username' => $username));
        
        if ($user) {
            $userId = $user->get('id');
            $profile = $modx->getObject('modUserProfile', array('internalKey' => $userId));
            if ($profile) {
                $fullName = $profile->get('fullname');
                $modx->setPlaceholder('fullname', $fullName);
            }
        }
        return true;


        There may be an easier way, but I can't think of one.
          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
        • discuss.answer
          hi Bob,

          sorry for the delay'ed reply. well, it's not a dealbreaker to not have their name in the email; would've just been a nice-to-have. and since that code is over my head, more moreso, since you don't have much confidence in it, i think i'll just let it be.

          thanks again for your time & expertise!
          • It might work. wink

            If you want to try it, just paste that code into a plugin called FullName and add one of these to the Login and ForgotPassword tags (but not both).

            &postHooks=`FullName`
            &preHooks=`FullName`


            Put this in the email Tpl chunk:

            [[+fullname]]


            I think &preHooks is a better bet. If you already have pre- or post-hooks, add FullName ahead of them followed by a comma. Let me know if it works and I'll do a blog post on it.

            BTW, the Subscribe extra wraps the Register process for you, and IIRC, it sets a fullname placeholder for you.

              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
            • Hi Bob,
              Just to let you know that i tried your code above and it works with the preHook.
              Thanks very much;-)
                www.9thwave.co.uk
                   WEB | DESIGN | PRINT
              • I'm glad it worked for you. Thanks for the report. smiley
                  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