MyBB Community Forums

Full Version: Problem with url in a pm
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am working on a plugin which sends a pm with a link to a profile.

This is my code:

//Style link as BB Code for PM
		$newblink = "[URL=".$mybb->settings['bburl']."/member.php?action=profile&uid=".$user_info['uid']."]".$user_info['username']."[/URL]";
		
		$pmsubject = "New member referred by you.";
		$pm_message = "Thanks for referring me. Check out my profile ";
		$pm_message .= $newblink;

The pm gets sent fine, and the link is there, but my actual link is not working correctly. Instead of

http://www.testfish.leefish.nl/member.php?action=profile&uid=61

I get

http://www.leefish.nl.leefish.nl/member.php?action=profile&uid=61


Can anyone advise what I am doing wrong?
...looks like its somewhere else.

Why not print_r or die(print_r($check_it)) here and there ?
(2015-09-01, 12:25 PM)avril Wrote: [ -> ]...looks like its somewhere else.

I do not understand the comment Smile

That is the code as I have it - that is the whole thing.... Is it because its is a subdomain and the actual url is testfish.leefish.nl ?
Code you posted here looks ok, so the reason might be somewhere else.
In that case you will have to find out by 'step by step debugging'.

The fast and easy way could be reading throught code, analysing what it do and inserting print_r($something) to make sure that some variable in certain place, contain exacly what it should as we expect. ( sometime die(print_r($something)) is even better for this, as it stops execution )

I believe $mybb->settings['bburl'] should be as set in ACP, so first check whats exacly set in ACP ?
then insert die(print_r($mybb->settings['bburl'])) in code where you use it, to see if it really contain whats expected, then analyse further, read throught code and insert die(print_r($somevariable)) to see if this or that variable contain exacly what you believe it should at that time and place.

Its fastest way to find out whats wrong when 'everything looks ok but gives unexpected output'

thats what i meant.
Yea, I did all those things Avril re checking the ACP, I also have in fact checke through my code. The code is supposed to output in the body of a pm. I think it is the subdomain period causing it?

This is the bit where I output the code:

//Style link as BB Code for PM
		$newblink = "[URL=".$mybb->settings['bburl']."/member.php?action=profile&uid=".$user_info['uid']."]".$user_info['username']."[/URL]";
		
		$pmsubject = "New member referred by you.";
		$pm_message = "Thanks for referring me. Check out my profile ";
		$pm_message .= $newblink;

		require_once MYBB_ROOT."inc/datahandlers/pm.php";
		$pmhandler = new PMDataHandler();
		
		//PM will always be sent regardless of receivers settings
		$pmhandler->admin_override = true;
		$pm = array(
			"subject" => $pmsubject,
			"message" => $pm_message,
			"icon" => "-1",
			"toid" => $toid,
			"fromid" => $new_uid,
			"do" => '',
			"pmid" => ''
		);

That is it.

This is the actual plugin : https://github.com/leefish/showrefer but I am finetuning, removing hardcoded html etc. It does work.
tested your GH code on localhost and everything worked ok. (both profile and received pm had valid link)
Also registered on your testfish site and it seems ok (can see valid link in 'ReferTest's Forum Info', but pm was send to ReferTest so i cant check it)

Hmm... definitely this is that kind of a bug which makes us pull hairs out, hehe...
maybe theres another plugin which use for eg. "datahandler_pm_validate" hook and do stuff there ?
you gota trace this variable from begining when its created until it reach db table.
Is it broken in db table or its good there, then maybe it 'changes' on output when pm is displayed ?
Right, its just the pm. For some reason its redoing my url. Maybe something on my server?
I found it. I cannot believe I spent all day on this. I have a wordfilter plugin I was testing and it is affecting my url....

Thank you for the help
haha, i knew its somewhere else Smile  Nice.
On a side note, you could have used get_profile_link($user_info['uid']): https://github.com/mybb/mybb/blob/featur...5750-L5756 which is simplier/cleaner and works with Google SEO URLs.
Pages: 1 2