SimplePortal
Customization => Custom Coding => Topic started 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?
-
MalibuzOr,
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>';
-
Thanks!
-
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".
-
MalibuzOr,
Creating your own function will work but is unnecessary. Temporarily change the user id & then back again.
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;