<tfoot id='TYa0E'></tfoot>

    <bdo id='TYa0E'></bdo><ul id='TYa0E'></ul>

    <small id='TYa0E'></small><noframes id='TYa0E'>

    <legend id='TYa0E'><style id='TYa0E'><dir id='TYa0E'><q id='TYa0E'></q></dir></style></legend>
  • <i id='TYa0E'><tr id='TYa0E'><dt id='TYa0E'><q id='TYa0E'><span id='TYa0E'><b id='TYa0E'><form id='TYa0E'><ins id='TYa0E'></ins><ul id='TYa0E'></ul><sub id='TYa0E'></sub></form><legend id='TYa0E'></legend><bdo id='TYa0E'><pre id='TYa0E'><center id='TYa0E'></center></pre></bdo></b><th id='TYa0E'></th></span></q></dt></tr></i><div id='TYa0E'><tfoot id='TYa0E'></tfoot><dl id='TYa0E'><fieldset id='TYa0E'></fieldset></dl></div>

      1. 添加 url() 会破坏 hook_mail 实现

        Adding url() breaks hook_mail implementation(添加 url() 会破坏 hook_mail 实现)
        • <tfoot id='6SQMI'></tfoot>

            <small id='6SQMI'></small><noframes id='6SQMI'>

          1. <i id='6SQMI'><tr id='6SQMI'><dt id='6SQMI'><q id='6SQMI'><span id='6SQMI'><b id='6SQMI'><form id='6SQMI'><ins id='6SQMI'></ins><ul id='6SQMI'></ul><sub id='6SQMI'></sub></form><legend id='6SQMI'></legend><bdo id='6SQMI'><pre id='6SQMI'><center id='6SQMI'></center></pre></bdo></b><th id='6SQMI'></th></span></q></dt></tr></i><div id='6SQMI'><tfoot id='6SQMI'></tfoot><dl id='6SQMI'><fieldset id='6SQMI'></fieldset></dl></div>

                <tbody id='6SQMI'></tbody>
                  <bdo id='6SQMI'></bdo><ul id='6SQMI'></ul>
                  <legend id='6SQMI'><style id='6SQMI'><dir id='6SQMI'><q id='6SQMI'></q></dir></style></legend>
                  本文介绍了添加 url() 会破坏 hook_mail 实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在用 Drupal-7 编写一个模块,该模块动态地向访客发送一次性登录链接.一切正常,直到我将链接添加到 $message 数组,当它窒息时.如果我执行 dpm($message) 链接会出现在 $message['body'] 数组中,正如我所期望的.如果我用 url() 函数注释掉该行,则一切正常.为什么 php/Drupal 在这个愚蠢的小链接上卡住了?

                  I'm writing a module in Drupal-7 that dynamically sends a one-time login link to guests. Everything fires fine until I add the link to the $message array, when it chokes. If I do a dpm($message) the link appears in the $message['body'] array, as I would expect. If I comment out the line with the url() function, everything works as it should. Why is php/Drupal choking on this silly little link?

                  /*
                   * Implement hook_mail().
                   */
                  
                  function rsvp_mail($key, &$message, $params) {
                      switch($key) {
                        case "send invite" :
                          $timestamp = REQUEST_TIME;
                          $account = $params['account'];
                          $message['subject'] = "And invitation for $account->name";
                          $message['body'][] = 'Some body text.';
                          $message['body'][] = 'Some more text!';
                          //here's the line that's breaking my brain:
                          $message['body'][] = url( 'http://wedding.juicywatermelon.com/rsvp/' . $account->uid . "/" . $timestamp . "/" . md5($account->pass . $timestamp) . "/" . 'user/' . $account->uid . '/edit/Wedding');             
                          break;
                      }
                    }
                  

                  ps - 为简洁起见,我有代码在单独的函数调用中生成链接并将其移至钩子实现.然而,这对行为没有影响.

                  ps - I had the code to generate the link in a seperate function call and moved it to the hook implementation for brevity. This, however had no effect on the behaviour.

                  以及生成电子邮件的代码:

                  and the code that generates the email:

                  function rsvp_mail_send($account) {
                    $module = 'rsvp';
                    $from = "email@gmail.com";
                    $key = "send invite";
                    $params['account'] = $account;
                    $to = $account->mail;
                    $language = language_default();
                    $send = TRUE;
                    $result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
                  }
                  

                  推荐答案

                  你需要在 url() 函数中添加一个额外的参数,称为 options,它是一个数组,在这个数组中使用键 'absolute' 并设置将其设置为 TRUE 表示您作为第一个参数传递的 URI 是绝对 URL.

                  You need to add an extra argument to the url() function which is called options, it's an array and in this array use the key 'absolute' and set it to TRUE to indicate that the URI that you pass as a first argument is an absolute URL.

                  查看文档页面了解更多信息:http://api.drupal.org/api/drupal/includes--common.inc/function/url/7

                  See the documentation page for more information: http://api.drupal.org/api/drupal/includes--common.inc/function/url/7

                  这篇关于添加 url() 会破坏 hook_mail 实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How do I pass parameters into a PHP script through a webpage?(如何通过网页将参数传递给 PHP 脚本?)
                  PHP - include a php file and also send query parameters(PHP - 包含一个 php 文件并发送查询参数)
                  Where can I read about conditionals done with quot;?quot; and quot;:quot; (colon)?(我在哪里可以阅读有关使用“?完成的条件的信息?和“:(冒号)?)
                  Accessing arrays whitout quoting the key(在不引用键的情况下访问数组)
                  What is the name for the quot;lt;lt;lt;quot; operator?(“lt;lt;lt;的名字是什么?操作员?)
                  default as first option in switch statement?(默认为 switch 语句中的第一个选项?)
                  <legend id='nl9Aq'><style id='nl9Aq'><dir id='nl9Aq'><q id='nl9Aq'></q></dir></style></legend>
                  <tfoot id='nl9Aq'></tfoot>

                        <bdo id='nl9Aq'></bdo><ul id='nl9Aq'></ul>
                          <tbody id='nl9Aq'></tbody>
                      • <i id='nl9Aq'><tr id='nl9Aq'><dt id='nl9Aq'><q id='nl9Aq'><span id='nl9Aq'><b id='nl9Aq'><form id='nl9Aq'><ins id='nl9Aq'></ins><ul id='nl9Aq'></ul><sub id='nl9Aq'></sub></form><legend id='nl9Aq'></legend><bdo id='nl9Aq'><pre id='nl9Aq'><center id='nl9Aq'></center></pre></bdo></b><th id='nl9Aq'></th></span></q></dt></tr></i><div id='nl9Aq'><tfoot id='nl9Aq'></tfoot><dl id='nl9Aq'><fieldset id='nl9Aq'></fieldset></dl></div>

                          <small id='nl9Aq'></small><noframes id='nl9Aq'>