phpBB

Development Wiki

Difference between revisions of "Function.submit post"

From phpBB Development Wiki

(Add a few details on $data)
(Data Array)
Line 33: Line 33:
  
 
== Data Array ==
 
== Data Array ==
The $data array deserves further explanation.  Key items to note:
+
 
* The array is passed by reference.  The post ID of the submitted post will be available in $data after submit_post has been run.
+
<php>
* If you wish to submit a reply to a topic, pass that topic id in $data['topic_id']. If you want to create a new topic, give zero here.
+
// New Topic Example
* There is no way to change the poster or post time using this array.
+
$data = array(
 +
// General Posting Settings
 +
'forum_id' => 2, // The forum ID in which the post will be placed. (int)
 +
'topic_id' => 0, // Post a new topic or in an existing one? Set to 0 to create a new one, if not, specify your topic ID here instead.
 +
'icon_id' => false, // The Icon ID in which the post will be displayed with on the viewforum, set to false for icon_id. (int)
 +
 
 +
// Defining Post Options
 +
'enable_bbcode' => true, // Enable BBcode in this post. (bool)
 +
'enable_smilies' => true, // Enabe smilies in this post. (bool)
 +
'enable_urls' => true, // Enable self-parsing URL links in this post. (bool)
 +
'enable_sig' => true, // Enable the signature of the poster to be displayed in the post. (bool)
 +
 
 +
// Message Body
 +
'message' => $message, // Your text you wish to have submitted. It should pass through generate_text_for_storage() before this. (string)
 +
'message_md5' => md5($message),// The md5 hash of your message
 +
 
 +
// Values from generate_text_for_storage()
 +
'bbcode_bitfield' => $bitfield, // Value created from the generate_text_for_storage() function.
 +
'bbcode_uid' => $uid, // Value created from the generate_text_for_storage() function.
 +
 
 +
// Other Options
 +
'post_edit_locked' => 0, // Disallow post editing? 1 = Yes, 0 = No
 +
'topic_title' => $subject, // Subject/Title of the topic. It should pass through generate_text_for_storage() before this. (string)
 +
 
 +
// Email Notification Settings
 +
'notify_set' => false, // (bool)
 +
'notify' => false, // (bool)
 +
'post_time' => 0, // Set a specific time, use 0 to let submit_post() take care of getting the proper time (int)
 +
'forum_name' => '', // For identifying the name of the forum in a notification email. (string)
 +
 
 +
// Indexing
 +
'enable_indexing' => true, // Allow indexing the post? (bool)
 +
);
 +
</php>
 +
 
 +
This array is where all the data regarding the post gets passed. There is no way to change the author of the post via this array. You may access your new post id with the following after the submit post function is already ran:
 +
<pre>$data['post_id']</pre>

Revision as of 04:55, 13 August 2009

submit_post –– Posts a topic or post to the forum with the information supplied

Description

  1. mixed submit_post ( $mode,  $subject,  $username,  $topic_type,  &$poll,  &$data, [ $update_message = true])

To post a new message to the forums use the submit_post function. It handles all necessary changes. On success it returns the URL of the post, otherwise it returns false.

Parameters

Parameter Usage
mode Determines what type of posting should be done. Can be post, edit, reply, or delete.
subject The subject of the message.
username Username of the poster. Only valid for guest posters.
topic_type One of the phpBB3 topic type constants. POST_NORMAL, POST_STICKY, POST_ANNOUNCE, POST_GLOBAL
poll Poll data
data The post data in an array.
update_message (optional, default is true)

Data Array

// New Topic Example
$data = array( 
    
// General Posting Settings
    
'forum_id'            => 2,    // The forum ID in which the post will be placed. (int)
    
'topic_id'            => 0,    // Post a new topic or in an existing one? Set to 0 to create a new one, if not, specify your topic ID here instead.
    
'icon_id'            => false,    // The Icon ID in which the post will be displayed with on the viewforum, set to false for icon_id. (int)

    // Defining Post Options
    
'enable_bbcode'    => true,    // Enable BBcode in this post. (bool)
    
'enable_smilies'    => true,    // Enabe smilies in this post. (bool)
    
'enable_urls'        => true,    // Enable self-parsing URL links in this post. (bool)
    
'enable_sig'        => true,    // Enable the signature of the poster to be displayed in the post. (bool)

    // Message Body
    
'message'            => $message,        // Your text you wish to have submitted. It should pass through generate_text_for_storage() before this. (string)
    
'message_md5'    => md5($message),// The md5 hash of your message

    // Values from generate_text_for_storage()
    
'bbcode_bitfield'    => $bitfield,    // Value created from the generate_text_for_storage() function.
    
'bbcode_uid'        => $uid,        // Value created from the generate_text_for_storage() function.

    // Other Options
    
'post_edit_locked'    => 0,        // Disallow post editing? 1 = Yes, 0 = No
    
'topic_title'        => $subject,    // Subject/Title of the topic. It should pass through generate_text_for_storage() before this. (string)

    // Email Notification Settings
    
'notify_set'        => false,        // (bool)
    
'notify'            => false,        // (bool)
    
'post_time'         => 0,        // Set a specific time, use 0 to let submit_post() take care of getting the proper time (int)
    
'forum_name'        => '',        // For identifying the name of the forum in a notification email. (string)

    // Indexing
    
'enable_indexing'    => true,        // Allow indexing the post? (bool)
);

This array is where all the data regarding the post gets passed. There is no way to change the author of the post via this array. You may access your new post id with the following after the submit post function is already ran:

$data['post_id']