returning a $var in email activation tut

Post here is you are having problems with any of the tutorials.
Post Reply
shaunthomson
Posts: 19
Joined: Mon Nov 28, 2011 11:53 am

returning a $var in email activation tut

Post by shaunthomson »

Hi

I've been customising the email registration php, and have come a ways with it. I've added a few more processes to the activation, including setting up a user directory. And it seems to be working.

Now I'd like to return to activate.php a true value for when the dir set up (which is the last process) is successful.

I can't seem to get a var returned though.

So activate.php has:
if(isset($_GET['aid'])) {
		
		activate_account($_GET['aid']);		
		
	}
Then in user.inc.php...
function activate_account($aid) {}   
activates, then
make_user_dir($user_dir); 
runs
function make_user_dir($user_dir) {}
Everything works fine up to this point. Then, in make_user_dir, I put
$var = "successful";
return $var;
but I can't figure out how to get activate.php to echo $var

Is the fact that I've jumped from one function to another affecting the return?

Thanks guys

Shaun
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: returning a $var in email activation tut

Post by jacek »

Hmm, it would be possible using the session, but another method that you could consider using would be to have activate check to see if the last step has happened. The last step is creating a folder, if you know the path to that folder you could do
if (is_dir("user_folders/{$_SESSION['username']}")){
    // user has activated because their folder exists and that is the last step of activation.
}
You could even wrap it in a function
function is_user_activated($username){
    return is_dir("user_dirs/{$username}");
}
Image
Post Reply