hook_form_alter based on path
It looks like you have researched a few ideas and mixed them all.  The page--foo.tpl is a theme template file, and the names there are often used with theme suggestions so you can change the regions and wrapping html for different pages in different ways.  This is theme layer, and should be used for changing the appearance but not the processing.

The Hook_form_id_alter() is used to alter that specified form before it is passed to the theme layer, so that function will run before the print $foo; in the template.

So with what is in your question, the process would go like this:


  Check value of yet-to-be-set global $foo If foo is a specific page,
  remove field from form send form to theming get current page save
  current page to local $foo and ignore the global $foo that has already
  been checked. print out the value of local $foo into the html of the
  page


Also, I do not see roles touched anywhere in your question.  If I have read it right, you dont need the tpl at all and you can do this all in the form_alter.

function MYMODULE_form_user_register_form_alter(&amp;$form, &amp;$form_state) {
  global $user;
  if( current_path() == 'user/register/foo' ){
    // do what you want here
  }
}


Considerations.  Since you are using hook_form_ID_alter instead of hook_form_alter it is pretty safe to assume that this will only fire on the registration form so checking the registration url is a little redundant.  Since you are trying to define a function inside a function, you are used to javascript and the php scope handling is causing you some trouble; you should google for available drupal functions (like current_path() ) to help you before trying to write your own helper functions.