Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在用户以编程方式在drupal 7中注册时禁用邮件_Php_Email_Drupal_Drupal 7 - Fatal编程技术网

Php 如何在用户以编程方式在drupal 7中注册时禁用邮件

Php 如何在用户以编程方式在drupal 7中注册时禁用邮件,php,email,drupal,drupal-7,Php,Email,Drupal,Drupal 7,我将drupal commerce用于我的购物车项目,当用户注册到drupal站点时,会向用户邮件id发送邮件。但在我的项目中,当用户购买产品时,如果未注册,则会重定向到注册页面,注册后会自动登录到站点并重定向到购物车页面。我已经执行了所有场景,但当用户注册时,邮件被发送到其邮箱,如果用户在注册之前购买了产品,则我不需要该邮箱 这是我的密码 function user_verify_user_insert(&$edit, &$account, $category) { //

我将drupal commerce用于我的购物车项目,当用户注册到drupal站点时,会向用户邮件id发送邮件。但在我的项目中,当用户购买产品时,如果未注册,则会重定向到注册页面,注册后会自动登录到站点并重定向到购物车页面。我已经执行了所有场景,但当用户注册时,邮件被发送到其邮箱,如果用户在注册之前购买了产品,则我不需要该邮箱

这是我的密码

function user_verify_user_insert(&$edit, &$account, $category) {
  // Make sure that this rule only applies to users not
  // being created by admins. Also, if admin approval is
  // required, further verification would be useless.
  global $user;

  $order = commerce_cart_order_load($user->uid);
$quantity_total = 0;

if ($order) {
  $wrapper = entity_metadata_wrapper('commerce_order', $order);


   foreach ($wrapper->commerce_line_items as $delta => $line_item_wrapper) {
    $quantity = $line_item_wrapper->quantity->value();
    $quantity_total = $quantity_total + $quantity;
  }
}


  if (
    !user_access('administer users', $user)
    &&
    variable_get_value('user_register') == 1
  ) {
    $udata = new stdClass();
    $udata->uid = $account->uid;
    drupal_write_record('user_verify', $udata);
    if (
      (int)variable_get_value('user_verify_delay') == 0
    ) {
      _user_verify_send_code($udata);
    }



    if (variable_get_value('user_verify_lock') && _user_verify_load($account) && $quantity_total==0 ) {
        // modify the user's DB entry
        $account->status = 0;
        db_update('users')
        ->fields(array('status' => 0))
        ->condition('uid', $account->uid, '=')
        ->execute()
        ;
    }
   if ($quantity_total > 0) {

    $account->status = 1;


        db_update('users')
        ->fields(array('status' => 1))
        ->condition('uid', $account->uid, '=')
        ->execute()
        ;
     _user_verify_cleanup($account);
    $user = $account;
    $form_state['uid'] = $account->uid;
    user_login_submit(array(), $form_state);

  }     


  }
}


function user_verify_form_alter(&$form, &$form_state, $form_id)
{

    if($form_id==user_register_form)
    {
        $form['#submit'][] = 'user_verify_register_submit';

        unset($form['simplenews']['newsletters']);
        //$form['simplenews']['newsletters']['#attributes'] = array('checked'=> 'checked', 'style'=>'display:none');

    }


}

function user_verify_register_submit($form, &$form_state)
{
    $account = $form['#user'];
    if ((int)$account->status == 1) {


    $order_id = commerce_cart_order_id($account->uid);
    if ((int)$order_id > 0) {
        $form_state["redirect"] = url("checkout/" . $order_id); 

    }       

    }

}

也许你可以用更改邮件并将发送设置为false。 自闭症