Skip to Content Skip to Menu

Auto actions usecase question

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 402
  • Thanks: 37
  • Karma: 3
  • Add-ons
1 day 21 hours ago #340063 by liaskas
Auto actions usecase question was created by liaskas
we are using an auto action to set a cookie after user registration that holds the username as value.

hese is the cookie setting...

Triggers: OnAfterUserConfirmation
Type: Code
User Automatic
Acccess: Everybody
Action: (the following)

PHP method...

if (!isset($_COOKIE)) {
    $user = '[cookiename]';
    setcookie(
        'cookiename',
        $user,
        time() + (86400 * 120), // Expiration time: 120 days
        '/', // Path
        '.domain.com', // Domain
        true, // Secure (HTTPS)
        true  // HTTPOnly
    );
}


The cookie is created correctly (at least on some testing accounts i created).



Now...

with a second auto action we check to see if the coolie exists on user gegistration and if it exists we get a mail notification that someone that is already registered created a new account.

here is the cookie checking...

Triggers: OnAfterUserConfirmation
Type: Code
User Automatic
Acccess: Everybody
Action: (the following)

PHP method...

if (isset($_COOKIE)) {
    $cookieValue = $_COOKIE;
    $user = "[username]";
    $to = "myname@domain.com";
    $subject = "User $cookieValue registered again as $user";
    $txt = "Text to be sent in the body of the email";

    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n";
    $headers .= "From: info@xstream.gr";

    if ($user !== $cookieValue) {
        mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $txt, $headers);
    }
}


And here begins the problem...

Most of the e-mails we get are not true!
We might get an e-mail that User10 (last login was 2 months ago, auto actions were created 2 days ago) registered again as User2.

Where might the problem be?
Is it that the username substitution is not accurrate for this kind of auto action?
Is it that we have to populate the username some other way?
Is it that we have to use [user_id] instead of [username]?

Can you please advise?

Thank you

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum