Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 10-24-2014, 01:58 PM
ProfC's Avatar
ProfC ProfC is offline
 
Join Date: Jun 2011
Location: Coventry, UK
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Pre-filling the Recipient Box in newpm based on {option} in a bbcode.

Hi there,

I am attempting to trouble-shoot a custom bbcode for my forum which would pre-fill the recipient box of the "newpm" page with the userid of the user which featured in the {option} part of the custom bbcode.

The code is designed to use {option} to determine which profile to link to, and it does this, but we seem to have struck an issue in getting it to pre-fill the recipient box in the newpm page.

We appear to need the userid for this, but as I'm not sure on how to get it - it will be different for every user which uses the code. Such as: admin=admin1, admin=admin2 etc

Is there a way to convert the username of a poster (the contents of {option} in this case) to its userid so it'd work with the newpm page?

The specific line of code we're not sure about is this: (We've added the ____ as a placeholder)

Code:
<a  href="http://www.alexandria-ns.com/private.php?do=newpm&_____"><img  src="http://www.alexandria-ns.com/images/misc/message.png" alt="Send a  PM?"></a>
Any advice would be appreciated.

~ProfC


Full code:

Code:
<table cellspacing="0" style="border: solid #003399 1px; border-left: 0; width: 700px; background-color: #FFFFFF;"><tr><td style="width: 190px; border-left: solid #003399 4px; padding: 10px 15px; background-color: #003399; border-right: solid #003399 4px; border-top: solid #003399 1px; border-bottom: solid #003399 1px;" valign="top"> <h1 style="margin: 0; padding: 0;font-size: 11pt; font-weight: normal;"><a href="http://www.alexandria-ns.com/member.php?do=getinfo&amp;username={option}" target="_blank" onclick="javascript<b></b>:window.open(this.href, 'Profile of: {option}, 'width=800,height=400,resizable=yes, menubar=yes, scrollbars=yes, status=yes, toolbar=yes'); return false;" style="color: #e3dc0b;"><b>{option}</b></a></h1><p style="margin: 0; padding: 0;color: #e3dc0b; font-size: 8pt; padding: 3px 0;">Administrator's Comment</p><div style="margin-top: 10px;"></div><br><a href="http://www.alexandria-ns.com/private.php?do=newpm&_____"><img src="http://www.alexandria-ns.com/images/misc/message.png" alt="Send a PM?"></a> </td><td style="width: 440px; padding: 10px 15px; font-size: 8pt; border-right: solid #003399  4px; border-top: solid #003399  1px; border-bottom: solid #003399  1px;" valign="top"><b>{param}</b></td></tr></table>
Reply With Quote
  #2  
Old 10-24-2014, 02:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think member.php takes either &username=... or &userid=..., so maybe that would solve the problem.
Reply With Quote
  #3  
Old 10-24-2014, 02:59 PM
ProfC's Avatar
ProfC ProfC is offline
 
Join Date: Jun 2011
Location: Coventry, UK
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think member.php takes either &username=... or &userid=..., so maybe that would solve the problem.
I've tried that, but when we use "&username={option}" it just takes us to a new message without the recipient box containing the user in question.

As for "&userid=" I'm currently lost on how to link it to the username given in {option}. As vBulletin appears to use the userid to define the recipient when you click "Send PM" from their profile.

Screenshot: http://gyazo.com/322334da18a8c5cc915e5d6200c705a2 (Sorry for not posting one in sooner)
Reply With Quote
  #4  
Old 10-24-2014, 03:26 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I guess I was thinking that you could change the bbcode to take userid as the option, then use that in the profile link, but I guess you don't want to do that (I guess if a user is entering it then they don't want to have to look up the userid).

So what you could do is create a plugin using hook location private_newpm_blank and code like this:
Code:
$vbulletin->input->clean_gpc('r', 'username', TYPE_STRING);
if ($vbulletin->GPC['username'] != '')
{
        // validate username
	if ($user = $db->query_first_slave("SELECT userid FROM " . TABLE_PREFIX . "user WHERE username = '" . $db->escape_string($vbulletin->GPC['username']) . "'"))
       {
          if (empty($pm['recipients']))
             $pm['recipients']= $vbulletin->GPC['username']; 
         else
             $pm['recipients'] .= ' ; '.$vbulletin->GPC['username']; 
       } 
}

I haven't tested it but it looks like it should work.
Reply With Quote
Благодарность от:
ProfC
  #5  
Old 10-24-2014, 03:34 PM
ProfC's Avatar
ProfC ProfC is offline
 
Join Date: Jun 2011
Location: Coventry, UK
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That works perfectly, thank you so much.
Reply With Quote
  #6  
Old 10-24-2014, 03:40 PM
CoffeeLovesYou CoffeeLovesYou is offline
 
Join Date: Feb 2010
Posts: 176
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I understand your question, this already exists in vB.

Code:
http://www.website.com/forums/private.php?do=newpm&u[]=1&u[]=2&u[]=3&u[]=4&u[]=5
Reply With Quote
  #7  
Old 10-24-2014, 03:46 PM
ProfC's Avatar
ProfC ProfC is offline
 
Join Date: Jun 2011
Location: Coventry, UK
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CoffeeLovesYou View Post
If I understand your question, this already exists in vB.

Code:
http://www.website.com/forums/private.php?do=newpm&u[]=1&u[]=2&u[]=3&u[]=4&u[]=5
Thank you for your reply, the problem I was facing was trying to get the recipient name to autofill with the name displayed in:

http://gyazo.com/322334da18a8c5cc915e5d6200c705a2

The plugin code given to me by kh99 has sorted the matter and made me kick myself for not posting sooner. Much simpler and more straightforward than any option I've been looking at.
Reply With Quote
Благодарность от:
CoffeeLovesYou
Reply

Thread Tools
Display Modes

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 01:29 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.04616 seconds
  • Memory Usage 2,230KB
  • Queries Executed 13 (?)
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
  • (5)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (2)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete