20 Nov #1

Sending custom pm

Ultimate subscriber
Shade after using symposium sending custom pm via pm_handler doesnt seem to be working. It increases the number of PM's and sends the message, but those cannot be accessed.

require_once MYBB_ROOT . "inc/datahandlers/pm.php";
$pmhandler = new PMDataHandler();
$pmhandler->admin_override = true;

  $pm = [          "subject" => 'test',
                        "message" => 'test',
                        "fromid" => -1,
                        "toid" => [1]
                    ];
                    $pmhandler->set_data($pm);
                         if ($pmhandler->validate_pm()) {
                        $pmhandler->insert_pm();
                        echo 'PM sent';
                    }
  • 1
  • 2
Shade 20 Nov
#2
It should work as normal (you can see a demo here on MyBBoost itself: both Flyover and BankPipe notifications are delivered regularly). It might be an issue with either hooks priority or the fromid field (-1 might be an issue). I am not home but will check it out tomorrow.
ProX 21 Nov
#3
No idea, works normal without symposium, when symposium is enabled, pm just disappears because it contains no convid.
Shade 21 Nov
#4
It might indeed be an issue with hooks priority. Have you installed your plugin after Symposium? By design, Symposium adds convid when sending a PM through the handler (inc/plugins/symposium.php, line 1128, symposium_pm_insert_data); I can't really think about a scenario when this function does not run. A temporary FTP account might help me debug this, if you can.
ProX 21 Nov Edited
#5
I always test stuff locally :/

I run it as a new php file via my pages plugin from Omar g where you can create new php pages

When message is sent it needs to be converted via symposium converter to be shown

I am not sure if hooks can be loaded inside my pages?
Shade 21 Nov
#6
Do you have a name of the plugin? If hooks can't be loaded, the whole $plugins object is null.
ProX 21 Nov Edited
#7
Ougc pages is the name i think. Very popular one though


https://community.mybb.com/mods.php?action=view&pid=6
Shade 21 Nov Edited
#8
Mind sharing your page settings so I can replicate them? I tried creating a random page with your code and the following settings and it works just fine with Symposium:

[Image: zooSleY.png]

[Image: oBtyKMD.png]
ProX 21 Nov
#9
Use template wrapper and run at initialization set to yes in my case
Shade 21 Nov
#10
Still works good. The template is precisely the one you posted? If so, you have to wrap it inside <?php ?> tags to execute the code.