Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-12-2011, 05:30 PM
wolfey wolfey is offline
 
Join Date: Nov 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Email for PM change

OK
I would like to change the body of the email sent to users when a PM is received, currently the email will read:
Dear $touserinfo[username],

You have received a new private message at $vboptions[bbtitle] from $fromusername, entitled "$plaintext_title".

To read the original version, respond to, or delete this message, you must log in here:
$vboptions[bburl]/private.php

This is the message that was sent:
***************
$plaintext_message
***************

I would like to use a custom field I have setup to display the users "Real Name" I Have that inputed into "field2" of their profile
I dont know where/when the $fromusername collects the name...so I cant just put $bbuserinfo[field2] ? Can I

How do I do this?
Reply With Quote
  #2  
Old 02-13-2012, 10:32 AM
wolfey wolfey is offline
 
Join Date: Nov 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does anyone know if this can be done?
Reply With Quote
  #3  
Old 02-13-2012, 05:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The message is sent in function post_save_each() in includes/class_dm_pm.php. It looks like you could create a plugin using hook location pmdata_postsave_recipient to set a new value for $fromusername.
Reply With Quote
  #4  
Old 02-13-2012, 07:45 PM
wolfey wolfey is offline
 
Join Date: Nov 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh ok thats a start, except I have never worked with creating plugins

is there any resources here I can look at to learn a little more, or is there any plugins written close to what I need I can copy from
Reply With Quote
  #5  
Old 02-13-2012, 07:56 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's the manual page on creating a plugin: https://www.vbulletin.com/docs/html/main/add_plugin (or at least the instructions for using the admincp - it doesn't say much about the coding part). You just need to add some php code in the large text area that sets $fromusername to what you want. If you want to see where it will be executed, look at includes/class_dm_pm.php and search for 'pmdata_postsave_recipient'.
Reply With Quote
  #6  
Old 02-22-2012, 05:10 PM
Carpesimia Carpesimia is offline
 
Join Date: Jun 2011
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

I had the same need so I just got done writing and testing a similar plugin. Here it is:

Code:
    $ug = $user['usergroupid'];
    $admin_message = "";

    if (($user['options'] & $this->registry->bf_misc_useroptions['emailonpm']) AND ($ug == 5 OR $ug == 6))
    {
        $touserinfo =& $user;
        $plaintext_parser->set_parsing_language($touserinfo['languageid']);
        $admin_message = $plaintext_parser->parse($this->fetch_field('message'), 'privatemessage');

        $admin_message = "Message:\n*********\n" . $admin_message . "\n*********\n";
    }
Create a new plugin and set it to hook "pmdata_postsave_recipient", as said previously. Paste in the above code. In the IF statement, make sure all of the usergroups you want to get your changes are listed.

In my above example, we normally dont show the contents of the PM. This way people have to come to the website to see what it said. Here, I'm checking if its a mod or an admin, and creating a NEW variable called admin_message. I then go into the pmreceived email template and add the new variable "$admin_message" to the template. This will only have a value if the PM is going to an admin or to a mod.

I hope this helps.
Reply With Quote
  #7  
Old 02-22-2012, 06:07 PM
wolfey wolfey is offline
 
Join Date: Nov 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK excellent start! as I have no idea how to creat a plugin using the data I need

So what could I do if I just needed to collect the data from $bbuserinfo[field2]
and have it displayed on the PM when sent

I think yours is a little more advance if I undertsand correctly?

Could I just add $bbuserinfo[field2] to the new variable "$admin_message"

Again, I am just trying to display the users real name that I have set in field2 to any PM sent by this usergroup

I really appreciate your help!

--------------- Added [DATE]1329938407[/DATE] at [TIME]1329938407[/TIME] ---------------

Sorry I know I got that wrong, you are setting the value of $admin_message only if its a mod or admin user

How could I use that to display the field 2?
Reply With Quote
  #8  
Old 02-22-2012, 06:55 PM
Carpesimia Carpesimia is offline
 
Join Date: Jun 2011
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, first you're gonna want to find the group of the user SENDING your PM. This might be as easy as checking:

$vbulletin->userinfo['usergroupid'];

So in MY example, you would test for $vbulletin->userinfo['usergroupid'] == ### for the if. This makes sure that the logic is ONLY done for people of the usergroup you want. Then, make a variable (using admin_message is ok, since it is not used otherwise) and give it the value of $bbuser['field2'].

Should be straight forward, so long as those 2 variables are in scope. You may need to globalize them.

Anyone else wanna weigh in here?
Reply With Quote
  #9  
Old 02-22-2012, 07:13 PM
wolfey wolfey is offline
 
Join Date: Nov 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK thanks!
I am going to try this now

This will be awesome if it works...we have some admins that dont knnow who is sending them emails, because of the userid handle

--------------- Added [DATE]1329942354[/DATE] at [TIME]1329942354[/TIME] ---------------

OK, I feel dumb
.I am stuck on a small detail...

Where am I adding this new variable? Looking around cant find "pmreceived"

OR can I just put the $bbuserinfo[field2] right in the hook?

sorry to be a pain!
Reply With Quote
  #10  
Old 04-03-2012, 09:23 AM
wolfey wolfey is offline
 
Join Date: Nov 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cant get it to work, no errors just the results arent there

damn
Reply With Quote
Reply


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 11:51 AM.


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.04172 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete