Custom Fields
-
On my site I am the only one that can create a new topic (anyone can reply) I am trying to introduce a couple of pieces of text that will be added to the end of the content of each reply. (they are twitter names and twitter hashtags).
I have found this piece of code that allows me to add some input fields to a new topic but it only works at the front end, I have been trying with no luck to find a hook I can use to get this to work on the back end. Can any one help please ?
add_action ( ‘bbp_theme_before_topic_form_content’, ‘bbp_extra_fields’);
function bbp_extra_fields() {
$value = get_post_meta( bbp_get_topic_id(), ‘bbp_extra_field1’, true);
echo ‘<label for=”bbp_extra_field1″>hashtag</label><br>’;
echo “<input type=’text’ name=’bbp_extra_field1′ value='”.$value.”<br>’>”;
$value = get_post_meta( bbp_get_topic_id(), ‘bbp_extra_field2’, true);
echo ‘<br><label for=”bbp_extra_field2″>Twitter Name</label><br>’;
echo “<input type=’text’ name=’bbp_extra_field2′ value='”.$value.”‘>”;
}
/* Write out to meta table */
add_action ( ‘bbp_new_topic’, ‘bbp_save_extra_fields’, 10, 1 );
add_action ( ‘bbp_edit_topic’, ‘bbp_save_extra_fields’, 10, 1 );
$topic_id = bbp_get_topic_id();
function bbp_save_extra_fields($topic_id) {
if (isset($_POST) && $_POST[‘bbp_extra_field1’]!=”)
update_post_meta( $topic_id, ‘bbp_extra_field1’, $_POST[‘bbp_extra_field1’] );
if (isset($_POST) && $_POST[‘bbp_extra_field2’]!=”)
update_post_meta( $topic_id, ‘bbp_extra_field2’, $_POST[‘bbp_extra_field2’] );
}
- You must be logged in to reply to this topic.