MyBB Community Forums

Full Version: Account Switcher change author of post
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey again! 

We are running into a problem!

Link to forum: http://rebelwindrpg.com

We want to be able to switch the author of the post with relative ease. And while I know that this is possible, it shows up next to the little online man Icon and we don't want that.

So, I want to know if we can move it to a different place. Say, beside the username in place of the change user link (cause, for some reason, that just logs us out, and doesn't really switch the account) area. 

Would this be possible?

If you need a test account, please let me know. I have it all set up, but don't want to give it out without needing to.


http://i.imgur.com/YlgJNLO.png <--that ugly little triangle next to the online man is where it's currently at. We want to change it!

http://i.imgur.com/JHeDt7j.png <--see where my username is and how it's got the [change user] link? We want the change post author thing there. (these are mybb1.6 screen shots, not 1.8, but if you want to share how to do it for 1.8, I'd love you forever too!)
(2014-09-09, 09:05 PM)jenny loo who?! Wrote: [ -> ]So, I want to know if we can move it to a different place. Say, beside the username in place of the change user link (cause, for some reason, that just logs us out, and doesn't really switch the account) area.

It logs you out because it's a default MyBB function and isn't related to the account switcher. Big Grin


(2014-09-09, 09:05 PM)jenny loo who?! Wrote: [ -> ]Hey again! 

We are running into a problem!

Link to forum: http://rebelwindrpg.com

We want to be able to switch the author of the post with relative ease. And while I know that this is possible, it shows up next to the little online man Icon and we don't want that.

So, I want to know if we can move it to a different place. Say, beside the username in place of the change user link (cause, for some reason, that just logs us out, and doesn't really switch the account) area. 

Would this be possible?

If you need a test account, please let me know. I have it all set up, but don't want to give it out without needing to.


http://i.imgur.com/YlgJNLO.png <--that ugly little triangle next to the online man is where it's currently at. We want to change it!

http://i.imgur.com/JHeDt7j.png <--see where my username is and how it's got the [change user] link? We want the change post author thing there. (these are mybb1.6 screen shots, not 1.8, but if you want to share how to do it for 1.8, I'd love you forever too!)

1. It's not ugly.  Toungue

2. If you want to change the post author on edit post only:
For MyBB 1.8 (EAS 1.5) in inc/plugins/accountswitcher/as_functions.php

find:

$plugins->add_hook("postbit", "accountswitcher_author_change_button", 50);

and replace with:

$plugins->add_hook("editpost_end", "accountswitcher_author_edit_button");

function accountswitcher_author_edit_button()
{
	global $mybb, $theme, $lang, $loginbox;

	$lang->load("accountswitcher");

	if ($mybb->user['uid'] != 0 && $mybb->usergroup['as_canswitch'] == 1 && $mybb->settings['aj_changeauthor'] == 1)
	{
	    $loginbox = "<tr>
        <td class=\"trow1\" width=\"20%\"><strong>{$lang->username}</strong></td>
       <td class=\"trow1\">{$mybb->user['username']} <span class=\"smalltext\">[<strong><a href=\"javascript:MyBB.popupWindow('/editpost.php?pid={$mybb->get_input(pid, 1)}&amp;changeauthor=1')\">{$lang->aj_changeauthor_postbit}</a></strong>]</span></td>
     </tr>";
   }
}
(2014-09-09, 10:26 PM)doylecc Wrote: [ -> ]
(2014-09-09, 09:05 PM)jenny loo who?! Wrote: [ -> ]So, I want to know if we can move it to a different place. Say, beside the username in place of the change user link (cause, for some reason, that just logs us out, and doesn't really switch the account) area.

It logs you out because it's a default MyBB function and isn't related to the account switcher. Big Grin




(2014-09-09, 09:05 PM)jenny loo who?! Wrote: [ -> ]Hey again! 

We are running into a problem!

Link to forum: http://rebelwindrpg.com

We want to be able to switch the author of the post with relative ease. And while I know that this is possible, it shows up next to the little online man Icon and we don't want that.

So, I want to know if we can move it to a different place. Say, beside the username in place of the change user link (cause, for some reason, that just logs us out, and doesn't really switch the account) area. 

Would this be possible?

If you need a test account, please let me know. I have it all set up, but don't want to give it out without needing to.


http://i.imgur.com/YlgJNLO.png <--that ugly little triangle next to the online man is where it's currently at. We want to change it!

http://i.imgur.com/JHeDt7j.png <--see where my username is and how it's got the [change user] link? We want the change post author thing there. (these are mybb1.6 screen shots, not 1.8, but if you want to share how to do it for 1.8, I'd love you forever too!)

1. It's not ugly.  Toungue

2. If you want to change the post author on edit post only:
For MyBB 1.8 (EAS 1.5) in inc/plugins/accountswitcher/as_functions.php

find:



$plugins->add_hook("postbit", "accountswitcher_author_change_button", 50);

and replace with:



$plugins->add_hook("editpost_end", "accountswitcher_author_edit_button");

function accountswitcher_author_edit_button()
{
	global $mybb, $theme, $lang, $loginbox;

	$lang->load("accountswitcher");

	if ($mybb->user['uid'] != 0 && $mybb->usergroup['as_canswitch'] == 1 && $mybb->settings['aj_changeauthor'] == 1)
	{
	    $loginbox = "<tr>
        <td class=\"trow1\" width=\"20%\"><strong>{$lang->username}</strong></td>
       <td class=\"trow1\">{$mybb->user['username']} <span class=\"smalltext\">[<strong><a href=\"javascript:MyBB.popupWindow('/editpost.php?pid={$mybb->get_input(pid, 1)}&amp;changeauthor=1')\">{$lang->aj_changeauthor_postbit}</a></strong>]</span></td>
     </tr>";
   }
}

Will this also work for 1.6??

ETA: Tried this (and I might have done it wrong, but I swear I did all you said) and got this: http://i.imgur.com/l5g7xtj.png
(2014-09-10, 01:04 AM)jenny loo who?! Wrote: [ -> ]Will this also work for 1.6??

ETA: Tried this (and I might have done it wrong, but I swear I did all you said) and got this: http://i.imgur.com/l5g7xtj.png

MyBB 1.6 doesn't have the get_input() function.

Please try this code for the replacement with MyBB 1.6:

$plugins->add_hook("editpost_end", "accountswitcher_author_edit_button");

function accountswitcher_author_edit_button()
{
	global $mybb, $theme, $lang, $loginbox;

	$lang->load("accountswitcher");

	if ($mybb->user['uid'] != 0 && $mybb->usergroup['as_canswitch'] == 1 && $mybb->settings['aj_changeauthor'] == 1)
	{
	       $pid = (int)$mybb->input['pid'];
           $loginbox = "<tr>
        <td class=\"trow1\" width=\"20%\"><strong>{$lang->username}</strong></td>
       <td class=\"trow1\">{$mybb->user['username']} <span class=\"smalltext\">[<strong><a href=\"#\" onclick=\"MyBB.popupWindow('{$mybb->settings['bburl']}/editpost.php?pid={$pid}&amp;changeauthor=1', 'changeauthor', 420, 420);\">{$lang->aj_changeauthor_postbit}</a></strong>]</span></td>
     </tr>";
   }
}
Okay, that worked like a charm!

One real quick question though.

http://i.imgur.com/adt66e7.png <-- see how it still has Jenny as the poster? It shouldn't be Jenny after it's changed. It should be Command Central. It's not a big deal if we can't get it to reflect the new post author on edit, because it does reflect it when you've hit submit, but, how to we get it to reflect the new poster if we go back in and edit again?
(2014-09-10, 04:13 PM)jenny loo who?! Wrote: [ -> ]Okay, that worked like a charm!

One real quick question though.

http://i.imgur.com/adt66e7.png <-- see how it still has Jenny as the poster? It shouldn't be Jenny after it's changed. It should be Command Central. It's not a big deal if we can't get it to reflect the new post author on edit, because it does reflect it when you've hit submit, but, how to we get it to reflect the new poster if we go back in and edit again?

MyBB is showing the current username by default. If you are editing a post of another user as mod or admin, it shows your username, not the one of the post author.

To change it you could use this code instead of the above replacement:

$plugins->add_hook("editpost_end", "accountswitcher_author_edit_button");

function accountswitcher_author_edit_button()
{
    global $mybb, $theme, $lang, $loginbox, $post;

    $lang->load("accountswitcher");

    if ($mybb->user['uid'] != 0 && $mybb->usergroup['as_canswitch'] == 1 && $mybb->settings['aj_changeauthor'] == 1)
    {
           $pid = (int)$mybb->input['pid'];
           $user_name = htmlspecialchars_uni($post['username']);
           $loginbox = "<tr>
        <td class=\"trow1\" width=\"20%\"><strong>{$lang->username}</strong></td>
       <td class=\"trow1\">{$user_name} <span class=\"smalltext\">[<strong><a href=\"#\" onclick=\"MyBB.popupWindow('{$mybb->settings['bburl']}/editpost.php?pid={$pid}&amp;changeauthor=1', 'changeauthor', 420, 420);\">{$lang->aj_changeauthor_postbit}</a></strong>]</span></td>
     </tr>";
   }
} 

 
edit: fixed an error