Hi all. I have made a script for sincronizing phpBB3 and Drupal. It's working fine: all the account creation, login and logout procedures are carried by phpBB3. When you login to phpBB3, you are logged in drupal too. When you create a user in phpBB3, another one is created in Drupal, with the same ID.
Now I need to change the URLs generated by Drupal for showing profiles and login/logout actions, redirecting them to phpBB3.
I need to change 5 URLs, mainly:
?q=user/XX to forums/memberlist.php?mode=viewprofile&u=XX
?q=user/register to forums/ucp.php?mode=register
?q=user to forums/ucp.php?mode=login
?q=user/password to forums/ucp.php?mode=sendpassword
?q=logout to forums/ucp.php?mode=logout
Where in the drupal code are generated those URLs? Thank you!
Comments
Anyone?
Anyone?
..
Hi Xabi,
I'm not sure how this will impact the rest of your Drupal site, but, you could override the theme_username function so instead of pointing towards
userit points to the phpbb profile. The line you're looking for is:You can search the Drupal API for other theme functions, although, for the login logout stuff, I think it might be easier just to disable the Drupal LOGIN form and create your own custom login form and manually add a new LOGOUT link in your menu.
There are some examples of login forms here:
http://drupal.org/node/154233
Phil
Thank you, but I would need
Thank you, but I would need to override the login/register URLs too, it's not only a matter of login boxes... there are links like "Login or register to post comments" that I need to override :-)
I'm stuck here, I don't know
I'm stuck here, I don't know where these URLs are generated... I have tweaked user.module to no avail. Help!
Any clues out there? :-)
Any clues out there? :-)
Excuse me for bumping, but I
Excuse me for bumping, but I really need somebody pointing me in the right direction. Any ideas on how to replace those URLs?
Let's start with a simple one,
and see if it works. You should be able to override the menu items that are defined in user_menu() in user.module.
Make a custom module and put this in there:
Make sure you logout before testing, then go to user/register. If it works for user/register, see user_menu() in user.module for more of these menu items that you want to override. Note, you need to use if (!$may_cache), otherwise it won't work.
My drupal installation seems
My drupal installation seems broken after activating that module. I created .module and .info files and I got a blank page after activating it. Now the whole drupal installation is blank :-(
Edit: Deleting the module all works again.
Sorry for that.
The function name should be mymodule_menu, not user_menu (how can I edit that comment?).
So you need:
*a directory called mymodule inside sites/all/modules
*a file called mymodule.module in there, with the code that I posted and subsitituing user_menu by mymodule_menu.
*a file called mymodule.info in there like you did.
*to activate the module.
Does that work?
hey! it worked! Thanks! :-D
hey! it worked! Thanks! :-D But the resulting URL is rendered in this way: ?q=forums/ucp.php%3Fmode%3Dregister
Ok, got it.
Try this:
nope... it shows
nope... it shows forums/ucp.php&mode=register instead of forums/ucp.php?mode=register
Strange,
which version of Drupal are you using? I tested with 5.1, with the following code in mymodule.module:
And when I go to www.example.com/user/register, I'm redirected to www.example.com/forums/ucp.php?mode=register (and get a page not found).
The following might also work, but it's not so nice. Replace that 'callback arguments' line again, this time by:
Replacing example.com with your hostname.
Your second example works
Your second example works for me, thank you very much! Anyway, this function works only for unregistered users, isn't it? I need it working for registered and logged in users too...
One last thing: how could I add more items/redirections to this function? Which is the right format? Excuse me, I know only a bit of PHP.
Nice that it works.
Double post.
To allow this to work for all users,
you should replace
'access' => !$user->uid,by'access' => TRUE,. But I think logged in users are already registered aren't they, so they shouldn't be allowed to access user/register again.For more redirections, take a good look at the function user_menu() in user.module. Basically you just add more of these $items[] = array(.. , .. , .. ) parts after the one you already have in your custom module, using 'callback' => 'drupal_goto', etc. I think you'll be able to figure it out. Maybe only ?q=user/XX will be bit more difficult, if you need help, let me know.
Hi again. Some problems.
Hi again. Some problems. This is the code I'm using:
Only the user/register redirection works. The another three give errors like this: warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, 'http://www.mydomain.com/foros/ucp.php' was given in /XXX/includes/form.inc on line 218.
And last one: I can't find what to do with the user/XX (user ID) redirection... User IDs are the same in drupal and phpBB, so I just need to do a redirection from, for example, user/23 to /forums/memberlist.php?mode=viewprofile&u=23. It "seems" easy...
Thank you for your help!
Excuse me, I did not put
Excuse me, I did not put "drupal_goto'" in all callbacks! Now it seems to work! I would only need to redirect the URLS like user/45 and user/45/edit. Have you any clues?
Hey, user/X/edit URLs are
Hey, user/X/edit URLs are redirected with this one!
Now I'm trying the last one: user/XX. I'm near, but I can't get it to work yet. This is my code:
Any clues? THANK you!
Ok... done! Thank you very,
Ok... done for user/X. The whole code has some issues, anyway. I'll post them here in a while.
My module stopped working
My module stopped working after installing Drupal 5.2 :-( Any idea of what's happening? Thank you.