CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Redirecting /user/register both clean and UNCLEAN URL's to a Civi Join node
Pages: [1]

Author Topic: Redirecting /user/register both clean and UNCLEAN URL's to a Civi Join node  (Read 3813 times)

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Redirecting /user/register both clean and UNCLEAN URL's to a Civi Join node
September 09, 2013, 12:08:19 pm
I have not gotten an answer on this question in the Drupal support forums:

"Way to redirect non clean URL by using a theme function"
https://drupal.org/node/2082733

Quote
I manage a site which uses both Drupal (6) and CiviCRM. We must have the security setting for creation of Drupal user accounts set to "wide open" as CiviCRM is responsible for provisioning accounts.

Thus, I have a simple redirect as follows:

Code: [Select]
# .htaccess
# Redirect Drupal anonymous create user account to the Membership Levels page
redirect 301 /user/register http://domain.org/Membership_Levels

which works splendidly, except... using the non-clean URL does not get picked up by that 301 rule. I came across this post:

http://drupal.stackexchange.com/questions/18020/redirect-user-register-t...

which mentioned creating a theme function. I have done so, and have not gotten it to work. I am attempting to "clean up" the suggested code based on the Drupal API reference, so my current code (which is still not working) is as follows:

Code: [Select]
<?php
/*
* Customization of Drupal User Registration
*/
function cir_preprocess_page(&$variables, $hook) {
  if(
arg(0) == "user" && arg(1) == "register") {
    
drupal_goto("Membership_Levels");
  }
}
?>

Suggestions as to what I am missing in order to get this seemingly simple and elegant solution working?

Since the reason the configuration exists is for CiviCRM to be able to work properly, perhaps someone in this CiviCRM forum would be kind enough to provide a working way to redirect both clean and UNCLEAN URL syntax. The Theme function looked promising to me... I sure wish it would just work and not be so cranky! I saw that as a single way to scoop up both clean and UNCLEAN URL's in the same code. Would I be correct?

Thank you!
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Redirecting /user/register both clean and UNCLEAN URL's to a Civi Join node
September 10, 2013, 04:56:29 am
Everything you wrote is correct, including your understanding of Drupal and your code itself offhand looks correct.

There is simply a small bug in it which you must find. Try adding:

Code: [Select]
drupal_set_message( '<pre>' . print_r($variables,1) . '</pre>');
To see if your code is indeed executing. Or just try die; to make sure it's running. If die; works then try to print arg(0); and arg(1) and see what happens.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Re: Redirecting /user/register both clean and UNCLEAN URL's to a Civi Join node
September 13, 2013, 10:50:45 am
Thank you, Hershel.

I remembered my post today, so came back to see if there were any responses. In the mean time, mysteriously dirty URL syntax is getting redirected.

I removed my one redirect rule in .htaccess, and redirection of both clean/unclean URL's is firing.

Then I noticed clear at the bottom of .htaccess something that I do not know when this got added:

Code: [Select]
# .htaccess

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  #Added to have the redirect to CiviCRM work properly
  RewriteCond %{REQUEST_URI} !=/user/register
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

I do not recall adding that bit after "Added to have the redirect to CiviCRM work properly" while attempting to redirect unclean user registration.

Anyway, I shall keep my eye on it to make sure it really does keep working as needed. Perhaps it just took a while for the template.php file to be reread from disk? ggggrrrr.... I do NOT like mysteries!
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Redirecting /user/register both clean and UNCLEAN URL's to a Civi Join node

This forum was archived on 2017-11-26.