public static function userCreateForm(&$template)
 {
     global $wgRequest, $wgCustomUserSignupVersion, $wgCustomUserSignupSetBuckets;
     $titleObj = SpecialPage::getTitleFor('Userlogin');
     $newTemplate;
     $linkmsg;
     $campaign = CustomUserSignupHooks::getCampaign();
     if ($campaign != "") {
         if ($template instanceof UserloginTemplate) {
             $newTemplate = new CustomUserloginTemplate();
             $linkmsg = 'nologin';
             $template->data['action'] = "{$template->data['action']}&campaign={$campaign}";
             $template->data['link'] = preg_replace('/type\\=signup/', "campaign={$campaign}&type=signup", $template->data['link']);
         } elseif ($template instanceof UsercreateTemplate) {
             $newTemplate = new CustomUsercreateTemplate();
             $linkmsg = 'gotaccount';
             $template->data['action'] = "{$template->data['action']}&campaign={$campaign}";
             $template->data['link'] = preg_replace('/type\\=login\\&/', "type=login&campaign={$campaign}&", $template->data['link']);
         } else {
             return true;
         }
         //set bucket if not set already
         if ($wgCustomUserSignupSetBuckets && $wgRequest->getCookie('UserName') == NULL) {
             //do not put users who already have a username in a bucket
             $buckets = ClickTrackingHooks::unpackBucketInfo();
             if (!isset($buckets["AccountCreation"]) || $buckets["AccountCreation"][1] < $wgCustomUserSignupVersion) {
                 $buckets["AccountCreation"] = array($campaign, $wgCustomUserSignupVersion);
                 ClickTrackingHooks::packBucketInfo($buckets);
             }
         }
         // replace "gotaccount" and "nologin" links
         if ($template->data['link'] != '') {
             // get the link part of the message
             $originalLinkFull = $template->data['link'];
             $originalLinkMessage = wfMsg($linkmsg);
             $leftOfLink = substr($originalLinkMessage, 0, strpos($originalLinkMessage, '$1'));
             $linkq = substr($originalLinkFull, strlen($leftOfLink) + 9);
             $linkq = substr($linkq, 0, strpos($linkq, '">'));
             $link = '<a href="' . $linkq . '">';
             if (wfMessage("customusertemplate-{$campaign}-{$linkmsg}" . 'link')->exists()) {
                 $link .= wfMsgHtml("customusertemplate-{$campaign}-{$linkmsg}" . 'link');
             } else {
                 $link .= wfMsgHtml($linkmsg . 'link');
             }
             $link .= '</a>';
             if (wfMessage("customusertemplate-{$campaign}-{$linkmsg}")->exists()) {
                 $template->set('link', wfMsgExt("customusertemplate-{$campaign}-{$linkmsg}", array('parseinline', 'replaceafter'), $link));
             } else {
                 $template->set('link', wfMsgExt($linkmsg, array('parseinline', 'replaceafter'), $link));
             }
         }
         $newTemplate->data = $template->data;
         $newTemplate->translator = $template->translator;
         $template = $newTemplate;
     }
     return true;
 }