1

I have a function like this

function login_redirect($redirect, $vars = array())
{
    return $redirect;
}

I would like to pass this variable in that array

$user = null

I tried like this

function login_redirect($redirect, $vars = array($user => null))
{
    return $redirect;
}

But I'm getting error. Can anyone correct me?

Thanks

2 Answers 2

3

You defined the array key incorrectly. The following works:

function login_redirect($redirect, $vars = array('user' => null))
{
    return $redirect;
}
Sign up to request clarification or add additional context in comments.

Comments

1

I'm assuming this is what you're trying to do:

function login_redirect($redirect, $vars = array())
{
    return $redirect;
}

// Redirect:
login_redirect("somepath", array("user" => $user));

Now the array you pass to login_redirect will contain the value of $user

2 Comments

Now I'm guessing this isn't what you're trying to do at all. I'll just stay here in the corner and try not to attract attention
Thanks for your answer. ThiefMaster's code working correctly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.