Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
Send PMs (automatically)
Andreas's Avatar
Andreas
Join Date: Jan 2004
Posts: 6,863

 

Germany
Show Printable Version Email this Page Subscription
Andreas Andreas is offline 06-09-2005, 10:00 PM

If you want to (automatically) send a PM to a user, you can use the Class vB_Datamanager_PM.
This class makes sure that all values are correct, handles quota for the recipients, notification eMails, etc.

Example

PHP Code:
// create the DM to do error checking and insert the new PM
$pmdm =& datamanager_init('PM'$vbulletinERRTYPE_ARRAY);
$pmdm->set('fromuserid'1234);
$pmdm->set('fromusername''Welcome-Bot');
$pmdm->set('title''Welcom to our Forums');
$pmdm->set('message'"Hello\nI am a Bot and would like to give you a warm welcome :)");
$pmdm->set_recipients('newuser'$botpermissions);
$pmdm->set('dateline'TIMENOW); 
If anything goes wrong you can check for errors using
PHP Code:
$pmdm->errors 
This is an erray containing the errors.

If everything is OK
PHP Code:
$pmdm->save(); 
This will send a PM to user newuser telling him
Quote:
Hello.
I am a Bot and would like to give you a warm welcome
The message will appear to be coming from User Welcom-Bot (Userid 1234).

$botpermissions must be the permissions for the sending user, but can just be empty.
If you want to send PMs no matter if the PM box of the recipient is full or not:

PHP Code:
$botpermissions['adminpermissions'] = 2
If you want, you can set other options as well ($pmdm->set_info(...)):
  • forward = 1/0 if this is a forwarded PM, Default=0
  • savecopy = 1/0 to keep a copy if the PM in outbox, Default=0
  • receipt = 1/0 to request a read-receipt, Default=0
  • parentpmid = ID of the PM you are responding to (if applicable)

Furthermore you can specify ($pmdm->set(...)):
  • iconid = ID of the message icon the PM should carry, Default=0
  • showsignature = 0/1 Whether the signature should be shown or not, Default=0
  • showsmilie = 0/1 Wheter smilies should be parsed or not, Default=1

For multiple receipients just use user1;user2;useer3.

This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent.
Reply With Quote
  #32  
Old 01-11-2006, 04:40 PM
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
Location: Black Lagoon
Posts: 1,090
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DigitalCrowd
Is anybody aware why when you send a pm from a given user to another user through the use of the sendpm code in this thread and found elsewhere, that no email is sent nor does it show a pop-up that you have a PM waiting.
I don't have that problem, there has to be a setting in your AdminCP or UserCP that is preventing the PM alert popup for you. For me, everything works just fine, as the PM datamanager has no control over whether or not the email is sent or the popup is shown, those are settings in the AdminCP, UserCP, or vBoptions.
Reply With Quote
  #33  
Old 01-11-2006, 04:53 PM
DigitalCrowd's Avatar
DigitalCrowd DigitalCrowd is offline
 
Join Date: Nov 2001
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually, it goes deeper than a pop-up. Even on the "Private Messages" for you under your username in the upper-right hand side of the default templates, it will show "0" even though I will have a new 1. EVEN if someone sends me a PM, it will show 1, when two are really available.

It's as though it thinks I have read it... but I haven't. It does show up as bold though likes its new , the PM area.
Reply With Quote
  #34  
Old 01-11-2006, 04:58 PM
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
Location: Black Lagoon
Posts: 1,090
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm at a loss, I am not experiencing any of those behaviors on the hack I wrote to send automatic PMs which i learned from reading this HOWTO. All the stuff in the top right, everywhere seems to work as it should on my installations of vb. Maybe it has to do with the location where you're inserting the datamanager code?
Reply With Quote
  #35  
Old 01-14-2006, 03:44 PM
JaeTea JaeTea is offline
 
Join Date: Jan 2006
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK I'm a little confused with PMing multiple users.

Suppose I have two textfields, user1 and user2.

All I want to do is combine those two values into the format user1;user2 and input that into the "$pmdm->set_recipients" line so I can send the PM to the two users specified.
Reply With Quote
  #36  
Old 01-14-2006, 04:46 PM
Developer's Avatar
Developer Developer is offline
 
Join Date: Sep 2005
Location: EgYpT
Posts: 662
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i am working on a new hack "Auto PM in members birthday"
i will use it as a cron jop but i have a proplem in recipient i can't make it sends the message to any member
Reply With Quote
  #37  
Old 01-23-2006, 09:30 PM
CrazyShooter CrazyShooter is offline
 
Join Date: Oct 2005
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am confussed, how do i make it so that a new user will get a private message automaticly sent by me saying Welcome?
Reply With Quote
  #38  
Old 02-01-2006, 05:48 PM
bulbasnore bulbasnore is offline
 
Join Date: Dec 2004
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm interested in some hints, or pointers to other tutorials, on how I might use this to PM a user when a mod delete's their message. I'd like to include the reason they list in the delete reason blank.
Reply With Quote
  #39  
Old 05-21-2006, 06:23 PM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This would be great to use as a "poke" sort of feature like facebook.com has, I'm not sure exactly how to do that at all - but it would be awesome to try ...
Reply With Quote
  #40  
Old 05-22-2006, 03:18 AM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the "poke" feature? Never heard of it.
Reply With Quote
  #41  
Old 05-22-2006, 05:45 AM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bulbasnore
I'm interested in some hints, or pointers to other tutorials, on how I might use this to PM a user when a mod delete's their message. I'd like to include the reason they list in the delete reason blank.
Take a look at the code for my "Moderation Auto-PM" hack - this should get you started with sending PM's when a post is deleted.

Thanks,
Alan.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:23 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05058 seconds
  • Memory Usage 2,307KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (3)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete