Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create New Topic button

  • @kriskl

    Participant

    Hi

    I would like to add Create New Topic button – and at the moment the only way to do it I found by using the plugin – bbp style pack
    (it works great, Robin, it’s a very comprehensive plugin) but it is the only feature I use – apart from refresh fixer which there is another plugin,

    So maybe there is a way to add ‘create new topic’ in a function file only?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @robin-w

    Moderator

    if you can do some basic editing and understand a bit of php, then this with some work shouldbe what you are after

    add_action ( 'bbp_template_before_single_forum', 'bsp_display_buttons' ) ;
    
    function bsp_new_topic_button () {
    	global $bsp_style_settings_buttons;
    	if (!empty ($bsp_style_settings_buttons['new_topic_description'] )) $text=$bsp_style_settings_buttons['new_topic_description'] ;
    	else $text=__('Create New Topic', 'bbp-style-pack') ;
    	if ($bsp_style_settings_buttons['button_type'] == 2)  $class=$bsp_style_settings_buttons['Buttonclass'] ;
    	else $class='bsp_button1' ;
    	if ( bbp_current_user_can_access_create_topic_form() && !bbp_is_forum_category() ) {
    	$href = apply_filters ('bsp_new_topic_button' , '#new-post' ) ;
    	echo '<a class="'.$class.'" href ="'.$href.'">'.$text.'</a>' ;
    	}
    }
    
    function bsp_create_new_topicb () {
    	echo '<div><a class="bsptopic" name="bsptopic"></a></div>' ;
    	}
    add_action( 'bbp_theme_before_topic_form', 'bsp_create_new_topicb' ) ;

    @ajtruckle

    Participant

    An alternative is to use the dedicated shortcode on a page:

    [bbp-topic-form]

    This is the best way I have found to allow a logged in user to create a topic. Then, you just link to this page from wherever.

    @kriskl

    Participant

    Hi Chuckie,
    yes, I was using your idea already, but with 8 forums and over 20 sub forums – it was not ideal therefore I wanted the create topic – like it is and should be in BBpress by default

    @kriskl

    Participant

    Hi Robin,

    thanks for the suggestion, of course I was looking at the code in the plugin before.. but it had overwhelmed me :))

    so, after your tip, here is what I ended up with,

    add_action ( 'bbp_template_before_single_forum', 'new_topic_button' ) ;
    
    function new_topic_button () {
    	if ( bbp_current_user_can_access_create_topic_form() && !bbp_is_forum_category() ) {
    	$text=__('Create New Topic') ;
    	$href = apply_filters ('new_topic_button' , '#new-post' ) ;
    	echo '<a class="new_topic_button" href ="'.$href.'">'.$text.'</a>' ;
    	}
    }
    

    probably there is a more elegant solution.. as the button didn’t want to go to a line below the breadcrumbs.. had to use css

    .new_topic_button {
    background-color: #0066CC;
    border: 0;
    border-radius: 5px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    padding: 15px 30px;
    text-decoration: none;
    width: auto;
    display: block;
    width: 200px;
    margin-top: 30px;
    }

    @robin-w

    Moderator

    great – glad you are fixed

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar