[Duda] Cambiar quién envía mensajes privados por defecto

Started by Jotade29, April 27, 2022, 08:24:08 PM

Previous topic - Next topic

Jotade29

Buenas, tengo la siguiente duda:

En varios mods, como la tienda, si haces 'x' acción, y recibes un mensaje privado, está configurado para que reciba el mensaje privado del usuario con id 1 (eso entiendo)

Facilitando el siguiente fragmento de código, ¿cómo podría hacer que el MP lo envíe el usuario, por ejemplo, con id 2?

// Who is receiving the IM
$pmto = array(
'to' => array($row['ownerid']),
'bcc' => array()
);
// The message subject
$subject = sprintf($txt['shop_im_trade_subject'], $row['name']);
// The actual message
$message = sprintf($txt['shop_im_trade_message'], $context['user']['id'], $context['user']['name'], $row['name'], formatMoney($row['tradecost']));
// Send the PM
sendpm($pmto, $subject, $message, 0, $pmfrom);

$context['shop_buy_message'] = sprintf($txt['shop_trade_bought_item'], $row['name'], $row['real_name']);

Entiendo que sea cosa de la variable $pmfrom, ¿debo crear otra que indique la id 2, o hay alguna posibilidad de especificar la id en esa variable?

Gracias.
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Dhayzon

#1
según  smf
 
array sendpm(array recipients, string subject, string message,
            bool store_outbox = false, array from = current_member, int pm_head = 0)
        - sends an personal message from the specified person to the
          specified people. (from defaults to the user.)
        - recipients should be an array containing the arrays 'to' and 'bcc',
          both containing id_member's.
        - subject and message should have no slashes and no html entities.
        - pm_head is the ID of the chain being replied to - if any.
        - from is an array, with the id, name, and username of the member.
        - returns an array with log entries telling how many recipients were
          successful and which recipients it failed to send to.
lo que te interesa

Quote- from is an array, with the id, name, and username of the member.

entonces tu $pmfrom seria

$pmfrom= array(
  'id'=> 2,
  'name'=>'nombre',
  'username'=>'username',
 
);

Jotade29

Definido el array no hay ningún problema. Muchas gracias por la ayuda  ;)

Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Advertisement: