Sledge81
Sledge81

Reputation: 23

Problem in activation key, using php

I'm using a custom login script for my wordpress installation. Everything works fine except that when the activation key is sent to registered users in the following format:

http://mydomain.com/?page_id=1278&[email protected]&activate_key=7edbad

When users click on the above link however, the '@' in the email disappears and therefore gives an error that the activation key is invalid.

Can someone guide me on this?

This is the piece of code that puts the activation link together:

$link=get_option('home').'/?page_id='.$pageid.'&mail='.$user_email.'&activate_key='.$key;

Upvotes: 1

Views: 632

Answers (3)

Ethan
Ethan

Reputation: 360

Try urlencode() around the $user_email to convert it to a URL-friendly value.

Upvotes: 0

Pascal MARTIN
Pascal MARTIN

Reputation: 401142

You probably need to encode the parameters in that URL, using the urlencode() function on each parameter's value :

$link=get_option('home')
            .'/?page_id='.urlencode($pageid)
            .'&mail='.urlencode($user_email)
            .'&activate_key='.urlencode($key);

As an alternative, you could also use [**`http_build_query()`**][2] once, to build up the whole query string :
$params = array(
    'page_id' => $pageid, 
    'mail' => $user_email, 
    'activate_key' => $key, 
);
$query_string = http_build_query($params);

$link=get_option('home') . '/?' . $query_string;

Upvotes: 1

alex
alex

Reputation: 490423

Try urlencode() on the GET params.

Upvotes: 0

Related Questions