Hi, sorry for bumping an old thread but I I'm having the exact same problem, when I create a post using submit_post it stays hidden 'till a mod approves it. I have posted manually in the same place so I know I have permissions. How did you solve this?
Thanks.
submit_post() question
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
- A_Jelly_Doughnut
- Registered User
- Posts: 1780
- Joined: Wed Jun 04, 2003 4:23 pm
Re: submit_post() question
icebrain: Normally that means $auth->acl() has not been run, or has been run for the a user who does not have posting without approval permissions in the given forum.
A_Jelly_Doughnut
Re: submit_post() question
"$auth->acl() has not been run" - what does that mean?A_Jelly_Doughnut wrote:icebrain: Normally that means $auth->acl() has not been run, or has been run for the a user who does not have posting without approval permissions in the given forum.
I cannot figure out how to get it to post with approval. I am posting with an admin account and it allways needs aproval. I know i have the forum permissions to post
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$auth->login('AdminUserName','AdminPassword');
$my_subject = utf8_normalize_nfc('Topic Subject Line');
$my_text = utf8_normalize_nfc('
Body
shown as
you want to see it.
');
$poll = $uid = $bitfield = $options = '';
generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);
$data = array(
'forum_id' => 82,
'icon_id' => false,
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
'enable_sig' => true,
'message' => $my_text,
'message_md5' => md5($my_text),
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
'post_edit_locked' => 0,
'topic_title' => $my_subject,
'notify_set' => false,
'notify' => false,
'post_time' => 0,
'forum_name' => '',
'enable_indexing' => true,
);
submit_post('post', $my_subject, '', POST_NORMAL, $poll, $data);
?>
Re: submit_post() question
I had the same problem, but i solved this by adding
at the very end in the $data array.
This posts everything, even in forums with admin only access, as guest if submit_post() is run with no user logged in.
Code: Select all
'force_approved_state' => true,
This posts everything, even in forums with admin only access, as guest if submit_post() is run with no user logged in.
Re: submit_post() question
hi all
I wrote a script that insert a new thread + replies.
here's the full code as example:
hope you like it
Bye
I wrote a script that insert a new thread + replies.
here's the full code as example:
Code: Select all
<?php
/**
* @ignore
*/
@set_time_limit(0);
//@ignore_user_abort(true);
@ini_set('memory_limit', '64M');
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
// Start first session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// function to insert a NEW POST/THREAD or an ANSWER to an existing one (depending by $topic_id value)
function crea_msg(&$topicid, $idforum, $titolo, $testo)
{
$my_subject = utf8_normalize_nfc($titolo);
$my_text = utf8_normalize_nfc($testo);
// variables to hold the parameters for submit_post
$poll = $uid = $bitfield = $options = '';
generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);
$data = array(
'forum_id' => $idforum, //2,
'icon_id' => false,
'topic_id' => ($topicid == 1) ? NULL : $topicid, // NULL if first post of a new thread; $topicid instead, to link this new post to the previous one created
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
'enable_sig' => true,
'message' => $my_text,
'message_md5' => md5($my_text),
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
'post_edit_locked' => 0,
'topic_title' => $my_subject,
'notify_set' => false,
'notify' => false,
'post_time' => 0,
'forum_name' => '',
'enable_indexing' => true,
);
if ($topicid == 1) {
submit_post('post', $my_subject, '', POST_NORMAL, $poll, $data);
} else {
submit_post('reply', $my_subject, '', POST_NORMAL, $poll, $data);
}
//update $topic_id to have as referral for next post
$topicid = $data['topic_id'];
}
/* 1st message */
//set $topic_id only for first message
$topic_id = 1;
//change message user creator
$user->data['user_id'] = 58;
//choose forum where you want insert the new thread/post
$id_forum = 2;
//title of the new thread/post
$title = 'Test nuova procedura import - 0';
//title of the new thread/post
$text = 'This is a test';
//launch funcion created before to insert a new post (if $topic_id = 1 will be a new thread - otherwise will be an answer to topic created on step before)
// *** in this case $topic_id = 1 so will be a new thread ***
crea_msg($topic_id, $id_forum, $title, $text);
//wait 2 secs before proceed - useful to have a correct message ordering inside the forum thread
sleep(2);
//change message user creator
$user->data['user_id'] = 60;
$id_forum = 2;
$title = 'Test nuova procedura import - 1';
$text = 'This is a test 1';
// *** in this case $topic_id != 1 so will be an answer to post before created ***
crea_msg($topic_id, $id_forum, $title, $text);
sleep(2);
//change message user creator
$user->data['user_id'] = 58;
$id_forum = 2;
$title = 'Test nuova procedura import - 2';
$text = 'This is a test 2';
// *** in this case $topic_id != 1 so will be an answer to post before created ***
crea_msg($topic_id, $id_forum, $title, $text);
//switch back to admin user
$user->data['user_id'] = 2;
?>
Bye