MyBB Community Forums

Full Version: New action on profile
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
At the moment I've added a link to all profiles like such:

<a href='profile.php?action=request&amp;uid=$uid&amp;my_post_key={$mybb->post_code}'>Request</a></td>

How would I then go about triggering an action, for example if($mybb->input['action'] == 'request'), from that link so I can then begin to run queries etc.?
What kind of actions you wanna perform with profile links? Something like this?
https://community.mybb.com/thread-151344.html
I'm creating a custom action within a plugin. At the moment, people are clicking the link I mentioned in the original post and getting a 404 error page. I want to run custom code when a user clicks that link. So for example:

HTML in Template:
<a href='profile.php?action=request&amp;uid=$uid&amp;my_post_key={$mybb->post_code}'>Request</a></td>

PHP in plugin:

				if(isset($mybb->input['request']))
		{
			verify_post_check($mybb->input['my_post_key']);

			$uid2 = intval($mybb->input['uid']);
			$query = $db->simple_select("users", "*", "uid='{$uid2}'");

			if($db->num_rows($query) == 0)
			{
				flash_message('Error', 'Error');
				redirect('profile.php?action=profile&uid=$uid');
			} else {
				$user = $db->fetch_array($query);
			}
// bit of code here
			flash_message('Success', 'Success');
			redirect('profile.php?action=profile&uid=$uid');
		}
<a href="member.php?action=profile&amp;uid=UID&amp;do=something&amp;my_post_key={$mybb->post_code}">Do Something</a>

if($mybb->get_input('do') == 'something')
{
verify_post_check($mybb->input['my_post_key']);
$uid = $mybb->get_input('uid', 1);
}

By default profile is the default action value to display profiles within the member.php file.
Ah shoot, I even done "profile.php". I dunno if I was tired or what when I wrote that. Thanks Omar!
(2018-04-16, 09:54 PM)Omar G. Wrote: [ -> ]
<a href="member.php?action=profile&amp;uid=UID&amp;do=something&amp;my_post_key={$mybb->post_code}">Do Something</a>

if($mybb->get_input('do') == 'something')
{
verify_post_check($mybb->input['my_post_key']);
$uid = $mybb->get_input('uid', 1);
}

By default profile is the default action value to display profiles within the member.php file.

So I've done this and within the if statement, I've sent a PM to whoever's profile the link is clicked on. Within the PM, is another link that goes like this:

[url=domain.com/private.php?action=read&do=accept&my_post_key={$mybb->post_code}]link here[/url]

Problem is, when the recipient presses that link the post_code coverts to a string, but still the recipient receives the authorized mismatch error. I've noticed that the post_code which is converted from the link within the PM is also the same post_code from the very first link from the profiles.

Anyone know why this is occurring?

If my explanation is confusing, here's a summary:

User A clicks link (<a href="member.php?action=profile&amp;uid=UID&amp;do=something&amp;my_post_key={$mybb->post_code}">Do Something</a>) on User B's Profile
User B receives an automated PM with another link (the link within the code area above)
When User B clicks link, authorized mismatch on post_code is shown

I've noticed the post_code is the same for User A and User B in both links.
$mybb->post_code corresponds to the user running the script. So the PM may be sent to X but if it was Y triggering the code, then $mybb->post_code will correspond to Y.

I don't know if I make myself clear but you aren't supposed to use it like that anyways.

You can add a confirmation step to your new page instead.
(2018-04-18, 04:56 AM)OmarĀ G. Wrote: [ -> ]$mybb->post_code corresponds to the user running the script. So the PM may be sent to X but if it was Y triggering the code, then $mybb->post_code will correspond to Y.

I don't know if I make myself clear but you aren't supposed to use it like that anyways.

You can add a confirmation step to your new page instead.

Ahhh I see, I understand. What did you mean by confirmation page?
From what I can infer, you are trying to add some, for the lack of a term, "security layer". Don't you ? You can simply add a confirmation page just as the one you see when using some moderation tools (Thread -> Inline Post Moderation -> Delete Thread Permanently). You could use $mybb->post_code in there too.