MyBB Community Forums

Full Version: Custom page with referral link
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to create custom page with referral link. I'm using {$post['uid']} at the end of link but it shows me nothing (no number at end).

I've created zapros.php page with this code

<?php

define("IN_MYBB", 1);
define("KILL_GLOBALS", 1);
require "global.php";

add_breadcrumb("ZaproĊ› znajomych", "zapros.php");

eval("\$zapros= \"".$templates->get("zapros")."\";");
output_page($zapros);
?>

Then I've created template zapros with this code:

<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
	<tr>
	<td class="trow1" valign="top">
			<div style="padding: 5px 0 5px 0;">
<div class="codeblock">
<div class="title">$lang->code</div>
<div class="body" dir="ltr">
<code>http://my-site.com/index.php?referrer={$post['uid']}</code>
</div>
</div><br>

</div>
</td>
</tr>
</table>
{$footer}
</body>
</html>

What did I wrong? how can I make referral link in custom page? Please help.
I think the only error I am seeing that this is your using of {$post['uid']}
Otherwise all other stuff + template is correct.
Try using this URL
http://my-site.com/member.php?action=register&referrername=XYZ
Change XYZ to your username
ghazal, I don't want to put my username in it. I want to something like that:
I go to this page and see this link: http://my-site.com/index.php?referrer=1 (my uid is 1).
Other user from my forum go to that page and see same link but with his uid, example http://my-site.com/index.php?referrer=2

I fought that I can use {$post['uid']} (It works in templates, I've inserted that code under avatar and it was showing poster uid). I think that i have to put some code into zapros.php that connect with DB and read uid.
NO. {$post['uid']} will get the user ID from postbit template. It will no longer be useful for pasting any other place of the forum.

The other way to paste the user ID number (e.g 1) in place of username, why not use the google SEO plugin. It will replace the username's with ID numbers.
Ok, I'll install Google SEO and than what? I can use referralname (or something like that) but how can I make variable username in page? example user noc sees http://my-site.com/index.php?referrername=noc, and user 123 sees http://my-site.com/index.php?referrername=123
No need to set variables for username in page. Google SEO will done it for you.
Problem solved. It's only need to put {$mybb->user['uid']} instead {$post['uid']} at the end and it creates variables links with uids. Google SEO is useless in this case.