function fb_example_init in Drupal for Facebook 6.3
Same name and namespace in other branches
- 7.3 contrib/fb_example.module \fb_example_init()
Implements hook_init().
Workaround for a problem with Drupal where a logged in user gets access denied when visiting the login or register pages. This can easily happen when clicking the facebook connect button on the login or register forms. Here will simply redirect the user to the profile page when that happens.
File
- contrib/
fb_example.module, line 363 - Example customizations to modules/fb.
Code
function fb_example_init() {
global $user;
if ($user->uid != 0) {
if (arg(0) == 'user' && (arg(1) == 'register' || arg(2) == 'login')) {
// Avoid Drupal's awkward access denied.
if (function_exists('fb_canvas_goto')) {
fb_canvas_goto('user');
}
else {
drupal_goto('user');
}
}
}
elseif (arg(0) == 'logout') {
// Avoid Drupal's awkward access denied.
if (function_exists('fb_canvas_goto')) {
fb_canvas_goto('<front>');
}
else {
drupal_goto('<front>');
}
}
}