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 »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Payment Page URLs
Pages: [1]

Author Topic: Payment Page URLs  (Read 366 times)

Max Hunter

  • I’m new here
  • *
  • Posts: 21
  • Karma: 1
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7
Payment Page URLs
July 10, 2013, 05:29:38 am
Hi All,

To avoid the un-sexy ampersands and question marks on payment page URLs, I have always used drupal_goto to redirect from something easy to remember like /join.  I suspect that this is a bad way to do things, but I'm not sure what would be better.

My understanding is that this is more of an issue with Drupal than with Civi, but I was wondering whether anyone knows of a workaround for it.  Thank you!

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Payment Page URLs
July 14, 2013, 10:40:05 am
I am not aware of another workaround, but you should put in a check that the URL is not cron.php in Drupal 6 as if not, it will process the drupal_goto when it comes to the page and it can end the cron processing. :)
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.

Max Hunter

  • I’m new here
  • *
  • Posts: 21
  • Karma: 1
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7
Re: Payment Page URLs
July 16, 2013, 07:12:00 pm
Thanks, Hershel!  Learned this one the hard way, and felt pretty foolish when I realized that my redirect had broken cron. 

In case anyone else made the same mistake, adding the PHP below fixes the issue in Drupal 6.

Code: [Select]
<?php
if(!function_exists('is_cron')){ //don't re-declare functions
  /**
   * function is_cron()
   * checks if cron is running, then stops the redirect
   */
  
function is_cron() {
    if (
php_sapi_name() == 'cli') {
      
// This may mean cron via Drush
      
return TRUE;
    }
    if(
preg_match('/\/cron.php$/', $_SERVER['SCRIPT_NAME'])) {
      
//check for cron.php in the url. *preg_match accommodates sites in sub-directories
      
return TRUE;
    }
    if (
arg(0) == 'admin' && arg(1) == 'reports' && arg(2) == 'status' && arg(3) == 'run-cron') {
      return 
TRUE;
    }
    return 
FALSE;
  }
//end function is_cron()
}//end if(!function_exists('is_cron')

//looks like Cron is running?  stop the redirect!
if(!is_cron()){
drupal_goto($path = 'civicrm/contribute/transact', 'reset=1&id=8');
}
//end if(!is_cron())
?>


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Payment Page URLs

This forum was archived on 2017-11-26.