Topic: Adding IP To Welcome email template (and so admin sees it)

I'm just wondering about adding the IP
would I add a line
        $mail_message = str_replace('<user_ip>',get_remote_address(), $mail_message);
or        $mail_message = str_replace('<user_ip>','registration_ip', $mail_message);
or        $mail_message = str_replace('<user_ip>',$registration_ip, $mail_message);
in include/functions.php

    ($hook = get_hook('fn_add_user_qr_insert_user')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $new_uid = $forum_db->insert_id();

    // Must the user verify the registration?
    if ($user_info['require_verification'])
    {
        // Load the "welcome" template
        $mail_tpl = forum_trim(file_get_contents(FORUM_ROOT.'lang/'.$forum_user['language'].'/mail_templates/welcome.tpl'));

        // The first row contains the subject
        $first_crlf = strpos($mail_tpl, "\n");
        $mail_subject = forum_trim(substr($mail_tpl, 8, $first_crlf-8));
        $mail_message = forum_trim(substr($mail_tpl, $first_crlf));

        $mail_subject = str_replace('<board_title>', $forum_config['o_board_title'], $mail_subject);
        $mail_message = str_replace('<base_url>', $base_url.'/', $mail_message);
        $mail_message = str_replace('<username>', $user_info['username'], $mail_message);
        $mail_message = str_replace('<activation_url>', str_replace('&amp;', '&', forum_link($forum_url['change_password_key'], array($new_uid, substr($user_info['activate_key'], 1, -1)))), $mail_message);
        $mail_message = str_replace('<board_mailer>', sprintf($lang_common['Forum mailer'], $forum_config['o_board_title']), $mail_message);

        ($hook = get_hook('fn_add_user_send_verification')) ? eval($hook) : null;

Re: Adding IP To Welcome email template (and so admin sees it)

I think you would need

$mail_message = str_replace('<user_ip>', $user_info['registration_ip'], $mail_message);

This will look for <user_ip> in the mail template and will replace with the IP address.

Is this what you wanted?

Re: Adding IP To Welcome email template (and so admin sees it)

excately big_smile thanks!
will test in a little...

Re: Adding IP To Welcome email template (and so admin sees it)

Well sadly that wasn't enough... there must be more places I need to add the 'registration_ip' to as the above alone didn't work... the email just shows the text
<user_ip>  smile

Re: Adding IP To Welcome email template (and so admin sees it)

Can you advise what template you added this into as what I put above should replace this string with the registration IP. I t should definitely not still be showing the string!

Please advise and I will check it for you!

Re: Adding IP To Welcome email template (and so admin sees it)

I put it in the welcome.tpl for testing...

Re: Adding IP To Welcome email template (and so admin sees it)

I just tested it on mine and it works. It sounds like you haven't added the line in functions hence the string is not being replaced. Please double check!!

Thanks

Re: Adding IP To Welcome email template (and so admin sees it)

Found the problem.
If I have pun_approval enabled that extension has a seperate functions.php which overrides the include/ one.
So I thought I'll just copy paste the line over to that functions at the right place.
Turns out $user_info is an undefined variable in that file...
Next I found that if I use $row it works.
So you're right, it works, thanks.

Re: Adding IP To Welcome email template (and so admin sees it)

Ah ok! Great to hear you have solved it!