• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Post a thread so looks like resource manager message

LPH

Well-known member
#1
I'd like to modify the following code so $body message posted to the new thread looks like what happens when a new resource is added or updated.

So, it would be a message stating a new blog entry has been created, then a trimmed quote, followed by a message to continue reading.

This issue I'm having is getting the user name to display in the $body 'submitted ...' section

PHP:
    $body = '';
        if($post_contains == 'full')
        {
            
            $body =   'submitted a new blog post';  // This is NOT correct
            
            $body .= '[quote]' . XenForo_Helper_String::autoLinkBbCode(XenForo_Html_Renderer_BbCode::renderFromHtml(nl2br($content))) . "[/quote]";
            
            /* Add preg_replace */
            $body = preg_replace('#\[nlposts .*\]#', '', $body);
            
            /* Add Trim to 500 Words */
            $body = XenForo_Helper_String::wholeWordTrim($body, 500);
        }

        $body .= "[URL='" . get_permalink($post->ID) . "']Continue reading the Original Blog Post[/URL]";

        $postWriter = $writer->getFirstMessageDw();
        $postWriter->set('message', $body);
        $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_ATTACHMENT_HASH, '');

        $writer->preSave();
Thank you for your help.
 

LPH

Well-known member
#2
I've tried {name} , username, $user['username'] ... any suggestion would be appreciated. It's probably obviously.
 

xf_phantom

Well-known member
#5
post your complete code

is this the xenscript bridge?
if yes you can use
PHP:
$XF->visitor->get('user_id'));
$XF->visitor->get('username'));
 

LPH

Well-known member
#6
OK. I looked at that earlier and didn't understand. That line calls a phrase and in the phrase is {username}. But I tried {username} and the site will not load. So maybe I'm not understanding how to write the $body line.

Should I build a phrase and try to rewrite the code that way? Can't I just pull the username another way?

Code:
{username} submitted a new resource:

[url={resourceLink}]{title}[/url] (version {version}) - {tagLine}

[quote]{snippet}[/quote]

[url={resourceLink}]Read more about this resource...[/url]
 

LPH

Well-known member
#7
post your complete code

is this the xenscript bridge?
if yes you can use
PHP:
$XF->visitor->get('user_id'));
$XF->visitor->get('username'));

This is the line I'm trying to get to post the username:

PHP:
$body = SOMETHING NEEDS TO GO HERE  'submitted a new blog post';  // This is NOT correct
Oh, and yes, this is the bridge.
 

LPH

Well-known member
#11
Well strip my gears and call me shiftless ... I know I tried that sucker hours ago... LOL. Anyway, the extra ) had to be removed but it's working.

PHP:
$body = $XF->visitor->get('username') . ' submitted a new blog post';
Now this looks much nicer !

Thank you all for the help.