turn username into a profile link
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: turn username into a profile link
Yep. The script used when sending PM.
The js could be found inside private_send_autocomplete template.
You need to modify it (especially for the ID of the input), and add an ID to your custom field.

Here is a simple example for that (assuming the field is a textbox):
Edit the field:
Allow multiple values for this field: Yes
Use Custom Input HTML: Yes
Input Field HTML:

HTML Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<input type="text" id="xtun" class="textbox"{NAME_PROP}{MAXLEN_PROP}{WIDTH_PROP_SIZE}{TABINDEX_PROP}{REQUIRED_PROP} value="{VALUE}" style="min-width: 300px;" />
<link rel="stylesheet" href="{$mybb->asset_url}/jscripts/select2/select2.css?ver=1806">
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/select2/select2.min.js?ver=1806"></script>
<script type="text/javascript">
<!--
if(use_xmlhttprequest == "1")
{
	MyBB.select2();
	$("#xtun").select2({
		placeholder: "Username(s), separated by comma. Maximum 3 users.",
		minimumInputLength: 3,
		maximumSelectionSize: 3,
		multiple: true,
		ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
			url: "xmlhttp.php?action=get_users",
			dataType: 'json',
			data: function (term, page) {
				return {
					query: term, // search term
				};
			},
			results: function (data, page) { // parse the results into the format expected by Select2.
				// since we are using custom formatting functions we do not need to alter remote JSON data
				return {results: data};
			}
		},
		initSelection: function(element, callback) {
			var query = $(element).val();
			if (query !== "") {
				var newqueries = [];
				exp_queries = query.split(",");
				$.each(exp_queries, function(index, value ){
					if(value.replace(/\s/g, '') != "")
					{
						var newquery = {
							id: value.replace(/,\s?/g, ", "),
							text: value.replace(/,\s?/g, ", ")
						};
						newqueries.push(newquery);
					}
				});
				callback(newqueries);
			}
		}
	});
}
// -->
</script>

* the above code based on 1.8.6. I don't have MyBB version above 1.8.6. So maybe you need to modify it a bit.

Multiple Value Delimiter: ,

Change the maximumSelectionSize if you are allowing more than 3 usernames.


02-15-2017 03:07 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
turn username into a profile link - foxxie - 02-08-2017, 07:57 AM
RE: turn username into a profile link - RateU - 02-15-2017 03:07 AM

 Standard Tools
Forum Jump: