I'm fairly new to Drupal, and I am currently working on a Drupal user registration mechanism that involves authentication on a different website. The flow is as follows: - A user registers on a Drupal user/register form. Using user_register_submit() I set the the user's status to blocked. - After registering, the user is being redirected to a different website where he is required to log in. In that redirect, I pass the newly registered Drupal username as a parameter. If the login on that external site is successful, I'd like to redirect the user back to a .php page on the Drupal site (also sending back the username parameter via POST), and then change the status of that user to Active.
In order to achieve that, I've tried using the following code in a page called auth.php I placed under my theme's root directory. This code is failing:
<?php $username = $_POST['user']; $user_to_activate = user_load(array('name' => $username)); user_save($user_to_activate, array('status' => 1); ?>
After stumbling upon this http://drupal.org/node/820506, I realized core functions (such as user_load() and user_save() from the user.module) should be available from other modules. So I'd like to put my code inside a custom module, thing is I don't know in which function should I put it. Also, I wouldn't want this module to be called on every page load, only when being redirected from the external website I mentioned in the first comment.
Could someone offer some guidance?