vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Pre-filling the Recipient Box in newpm based on {option} in a bbcode. (https://vborg.vbsupport.ru/showthread.php?t=315039)

ProfC 10-24-2014 01:58 PM

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>

kh99 10-24-2014 02:38 PM

I think member.php takes either &username=... or &userid=..., so maybe that would solve the problem.

ProfC 10-24-2014 02:59 PM

Quote:

Originally Posted by kh99 (Post 2519923)
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)

kh99 10-24-2014 03:26 PM

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.

ProfC 10-24-2014 03:34 PM

That works perfectly, thank you so much.

CoffeeLovesYou 10-24-2014 03:40 PM

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

ProfC 10-24-2014 03:46 PM

Quote:

Originally Posted by CoffeeLovesYou (Post 2519935)
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.


All times are GMT. The time now is 06:41 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01123 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete