• Hi

    I’ve been using wp_new_user_registration (code from Stackexchange here) to send a customised email to new users who register. I wrote a very quick plugin to achieve this, which works fine.

    What I’m trying to figure out is how to include the URL of the page that the user was on before they got to the login page (people have to register to see certain content, so I want to include the URL to enable them to get back to the page they were on).

    I’ve figured out how to display the URL on a page/template, by appending the referring page (eg. https://mydomain.com/?referer=https://mydomain.com/somepage ) using $_GET or a query_var, but I can’t figure out how to pass that to the function that sends the email to new users.

    I’ve tried adding an action to ‘register_post’ but with no luck.

    I’ve put my code so far in pastebin: https://pastebin.com/pD9CeHsA

    Any pointers would be much appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    The referring page is available as the php global $_SERVER['HTTP_REFERER'].

    Thread Starter papergecko

    (@papergecko)

    Thanks bcworkz.

    Do you know how to pass that to the custom wp_new_user_registration so I can send it in the registration email?

    Moderator bcworkz

    (@bcworkz)

    A php global… well actually it’s a superglobal. It is available in the scope of any function, you don’t need to pass it, nor declare it as global, just use it, for example:
    $message .= '<a href="' . $_SERVER['HTTP_REFERER'] . '">initial page</a>';

    Thread Starter papergecko

    (@papergecko)

    Many thanks, that worked perfectly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Include variable in custom new user registration email’ is closed to new replies.