SimplePortal

Customization => Custom Coding => Topic started by: Malibuz0r on February 06, 2013, 03:59:14 PM

Title: Other ways to submit shouts to shoutbox?
Post by: Malibuz0r on February 06, 2013, 03:59:14 PM
Is there a way to submit shouts by querying the info into mysql? I did tried it by manually entering the info into phpmyadmin, but they never show in the shoutbox. Any other way?
Title: Re: Other ways to submit shouts to shoutbox?
Post by: Chen Zhen on February 06, 2013, 04:20:01 PM

MalibuzOr,

Code: [Select]
global $context;

/* Set the shout message and opted shoutbox id */
$shout = 'This is a test shout';
$shout_id = 1;


$context['SPortal']['shoutbox'] = sportal_get_shoutbox($shout_id, true);

sportal_create_shout($context['SPortal']['shoutbox'], $shout);
echo '
<script language="Javascript" type="text/javascript"><!-- // --><![CDATA[
sp_submit_shout(', $shout_id, ', \'', $context['session_var'], '\', \'', $context['session_id'], '\');
// ]]></script>';
Title: Re: Other ways to submit shouts to shoutbox?
Post by: Malibuz0r on February 06, 2013, 04:35:28 PM
Thanks!
Title: Re: Other ways to submit shouts to shoutbox?
Post by: Malibuz0r on February 06, 2013, 04:53:22 PM
Sorry to bother, but just one last question; How do I enter a custom shoutbox poster name? Because when I load that code you provided, it sends the shout with my name.

Edit: Fixed. Made custom "sportal_create_shout".
Title: Re: Other ways to submit shouts to shoutbox?
Post by: Chen Zhen on February 06, 2013, 05:38:39 PM

MalibuzOr,

  Creating your own function will work but is unnecessary. Temporarily change the user id & then back again.

Code: [Select]
global $context, $user_info;
$user_name = $user_info['name'];
$user_id = $user_info['id'];


/* Set the shout message, opted shoutbox id & user id */
$shout = 'This is a test shout';
$shout_id = 1;
$user_info['id'] = 2;

$context['SPortal']['shoutbox'] = sportal_get_shoutbox($shout_id, true);

sportal_create_shout($context['SPortal']['shoutbox'], $shout);
echo '
<script language="Javascript" type="text/javascript"><!-- // --><![CDATA[
sp_submit_shout(', $shout_id, ', \'', $context['session_var'], '\', \'', $context['session_id'], '\');
// ]]></script>';

$user_info['id'] = $user_id;
SimplePortal 2.3.8 © 2008-2024, SimplePortal