bb_forum_form

The BuddyPress bb forum form function.

Description

bb_forum_form( (int) $forum_id = 0 ); 

Parameters (1)

0. $forum_id — Optional. (int)
The forum id.

Usage

  1. if ( !function_exists( 'bb_forum_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php'; 
  3.  
  4. // The forum id. 
  5. $forum_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_forum_form($forum_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php  
  1. function bb_forum_form( $forum_id = 0 ) { 
  2. $forum_id = (int) $forum_id; 
  3. if ( $forum_id && !$forum = bb_get_forum( $forum_id ) ) { 
  4. return; 
  5.  
  6. $forum_name = ''; 
  7. $forum_slug = ''; 
  8. $forum_description = ''; 
  9. $forum_position = ''; 
  10.  
  11. if ( $forum_id ) { 
  12. $forum_name = get_forum_name( $forum_id ); 
  13. $forum_slug = apply_filters('editable_slug', $forum->forum_slug);  
  14. $forum_description = get_forum_description( $forum_id ); 
  15. $forum_position = get_forum_position( $forum_id ); 
  16. $legend = __( 'Edit Forum' ); 
  17. $submit = __( 'Save Changes' ); 
  18. $action = 'update'; 
  19. } else { 
  20. $legend = __( 'Add Forum' ); 
  21. $submit = __( 'Add Forum' ); 
  22. $action = 'add'; 
  23.  
  24. $forum_options = array( 
  25. 'forum_name' => array( 
  26. 'title' => __( 'Name' ),  
  27. 'value' => $forum_name 
  28. ),  
  29. 'forum_slug' => array( 
  30. 'title' => __( 'Slug' ),  
  31. 'value' => $forum_slug 
  32. ),  
  33. 'forum_desc' => array( 
  34. 'title' => __( 'Description' ),  
  35. 'value' => $forum_description,  
  36. 'class' => 'long' 
  37. ),  
  38. 'forum_parent' => array( 
  39. 'title' => __( 'Parent' ),  
  40. 'type' => 'select',  
  41. 'options' => bb_get_forum_dropdown( array( 
  42. 'cut_branch' => $forum_id,  
  43. 'id' => 'forum_parent',  
  44. 'none' => true,  
  45. 'selected' => $forum_id ? get_forum_parent( $forum_id ) : 0,  
  46. 'disable_categories' => 0,  
  47. 'options_only' => true 
  48. ) ) 
  49. ),  
  50. 'forum_order' => array( 
  51. 'title' => __( 'Position' ),  
  52. 'value' => $forum_position,  
  53. 'class' => 'short' 
  54. ),  
  55. 'forum_is_category' => array( 
  56. 'title' => __( 'Category' ),  
  57. 'type' => 'checkbox',  
  58. 'options' => array( 
  59. 1 => array( 
  60. 'label' => __( 'Make this forum a category' ),  
  61. 'value' => bb_get_forum_is_category( $forum_id ),  
  62. ),  
  63. 'note' => __( 'Categories are forums where new topics cannot be created. Categories usually contain a group of sub-forums.' ) 
  64. ); 
  65.  
  66. if ( !$forum_id ) { 
  67. unset( $forum_options['forum_slug'] ); 
  68. unset( $forum_options['forum_order'] ); 
  69.  
  70. ?> 
  71. <form class="settings" method="post" id="<?php echo $action; ?>-forum" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" class="add:forum-list: forum-form"> 
  72. <fieldset> 
  73. <legend><?php echo $legend; ?></legend> 
  74. <?php 
  75. foreach ( $forum_options as $option => $args ) { 
  76. bb_option_form_element( $option, $args ); 
  77. ?> 
  78. <fieldset class="submit"> 
  79. <?php if ( $forum_id ) : ?> 
  80. <input type="hidden" name="forum_id" value="<?php echo $forum_id; ?>" /> 
  81. <?php endif; ?> 
  82. <?php bb_nonce_field( 'order-forums', 'order-nonce' ); ?> 
  83. <?php bb_nonce_field( $action . '-forum' ); ?> 
  84. <input type="hidden" name="action" value="<?php echo $action; ?>" /> 
  85. <input class="submit" type="submit" name="submit" value="<?php echo $submit; ?>" /> 
  86. </fieldset> 
  87. </fieldset> 
  88. </form> 
  89. <?php