Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom topic Fields

  • Hi folks,

    I want to use BBPress for a message/discussion board for doctors. However, the requirement is that every topic should start with a set of basic fields. This is because they are going to be talking about a particular condition at hand and we need that a combination of fields be selected and input to accompany the topic.

    I know WordPress now offers custom post type so you can add custom fields to a post. But can something similar be done with topics in BBpress? Has anyone tried something like that before?

    Thanks,

    -tejas

Viewing 23 replies - 26 through 48 (of 48 total)

  • christopher jon
    Member

    @christopher-jon

    “Did you have to call any additional function to add meta boxes? Have you tried that yet?”

    Nope. Using the default wordpress code should work. Just remember to set the correct page type (forum/topic) or you wont see it.

    Here is part of my code so you can see where I changed the page type to the “topic” custom post type.

    $meta_boxes[] = array(

    ‘id’ => ‘forum_options’,

    ‘title’ => ‘Forum Options’,

    ‘pages’ => array(‘topic’),

    ‘context’ => ‘side’,

    ‘priority’ => ‘core’,

    Thanks. The error I get is call to undefined function add_meta_box() in bbpress.php, so was wondering if it was supposed to be differently.

    Sorry about noobish questions! I am learning most of it. :)

    Thanks. The error I get is call to undefined function add_meta_box() in bbpress.php, so was wondering if it was supposed to be differently.

    Sorry about noobish questions! I am learning most of it. :)


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    @whitehats – You should never, ever, modify any core files. The WordPress actions/filters system is in place to let you inject code and modify existing values as needed. Anywhere you feel the need to hack the core, there should be another way.

    The only times when hacking core files makes sense are specifically when fixing a bug in the software or when creating new features to be inserted into core.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    @whitehats – You should never, ever, modify any core files. The WordPress actions/filters system is in place to let you inject code and modify existing values as needed. Anywhere you feel the need to hack the core, there should be another way.

    The only times when hacking core files makes sense are specifically when fixing a bug in the software or when creating new features to be inserted into core.


    christopher jon
    Member

    @christopher-jon

    What you should do is get a meta box working with pages and posts, there are a bunch of tutorials online to get you started.

    Once you have that working it’s just a matter of changing the post type so it’ll show up on the bbpress admin pages.


    christopher jon
    Member

    @christopher-jon

    What you should do is get a meta box working with pages and posts, there are a bunch of tutorials online to get you started.

    Once you have that working it’s just a matter of changing the post type so it’ll show up on the bbpress admin pages.

    Would you suggest that bbb-topic.php and bbb-metaboxes.php should not be modified even with hooks and actions?

    Would you suggest that bbb-topic.php and bbb-metaboxes.php should not be modified even with hooks and actions?

    Chris -

    Actually I do have an event post type working. I think I am only confused because the hooks I add in the function.php of bbbTwentyten theme do not affect the plugin files at all. So I went ahead and modified the files in my comment above.

    I do believe there is a better way of doing it. But probably will not realize until I break some stuff. :)

    Chris -

    Actually I do have an event post type working. I think I am only confused because the hooks I add in the function.php of bbbTwentyten theme do not affect the plugin files at all. So I went ahead and modified the files in my comment above.

    I do believe there is a better way of doing it. But probably will not realize until I break some stuff. :)

    Never mind the stupidity! I was jumping the gun too quickly.

    Will post my solution for a completely custom Topic a bit later. :)

    Never mind the stupidity! I was jumping the gun too quickly.

    Will post my solution for a completely custom Topic a bit later. :)


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    @whitehats – I cannot stress enough the importance of not modifying any core file, ever.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    @whitehats – I cannot stress enough the importance of not modifying any core file, ever.


    christopher jon
    Member

    @christopher-jon

    Sounds good.

    I’ve found working with the plugin to be pretty easy. Beneath all of the code, it’s still wordpress at heart.

    The next thing I want to try out is modifying the single topic loop to display certain topics with a different style, something similar to a featured post on a blog.

    This is where the meta box was needed, adding a check box to notify the loop to use a different style for those topics.

    The default theme has something similar already in place with the first topic posting having slightly larger text than the replies. An additional conditional check should do the trick.


    christopher jon
    Member

    @christopher-jon

    Sounds good.

    I’ve found working with the plugin to be pretty easy. Beneath all of the code, it’s still wordpress at heart.

    The next thing I want to try out is modifying the single topic loop to display certain topics with a different style, something similar to a featured post on a blog.

    This is where the meta box was needed, adding a check box to notify the loop to use a different style for those topics.

    The default theme has something similar already in place with the first topic posting having slightly larger text than the replies. An additional conditional check should do the trick.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    @christopher jon – Once you get your logic in order, hook into the ‘bbp_get_topic_class’ filter and add your custom classes to the table rows.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    @christopher jon – Once you get your logic in order, hook into the ‘bbp_get_topic_class’ filter and add your custom classes to the table rows.

    I have another (supposedly) silly question.

    I have added fields I need to the topic post type, thank you very much. However, I am finding it difficult to post them to the database when I enter any data from the frontend. I can add all the inputs to those fields from WordPress editor, but on-page fields fail on me.

    Can I just replicate bbp_form_topic_title() function and modify the new one to suit my needs?

    No Core Code has been harmed as yet.

    I have another (supposedly) silly question.

    I have added fields I need to the topic post type, thank you very much. However, I am finding it difficult to post them to the database when I enter any data from the frontend. I can add all the inputs to those fields from WordPress editor, but on-page fields fail on me.

    Can I just replicate bbp_form_topic_title() function and modify the new one to suit my needs?

    No Core Code has been harmed as yet.

    No one has tried anything like that before? :(

    No one has tried anything like that before? :(

Viewing 23 replies - 26 through 48 (of 48 total)

You must be logged in to reply to this topic.