Skip to:
Content
Pages
Categories
Search
Top
Bottom

BBP function to automatically make forms on separate pages?


  • Palagrin
    Participant

    @palagrin

    I know you can use shortcodes to add forms (such as new topic, login, new reply etc) to dedicated pages, but is there a fucntion or hook I can use to simply get BBP to automatically generate a new form page?

Viewing 15 replies - 1 through 15 (of 15 total)

  • Robin W
    Moderator

    @robin-w

    not sure what that means – render a screen with the form? or create a worpdress page ?

    perhaps you could describe what you want to achieve from what and to what.


    Palagrin
    Participant

    @palagrin

    Basically, instead of having the create topic / topic reply form on the same page as the thread I want to create a button that links to a secondary page. I know this is possible with shortcodes, but is there a way of doing this without shortcodes? So that BBP auto-generates the page itself?


    Robin W
    Moderator

    @robin-w

    ok, so your topic and reply forms will have pages with urls, so you just need to put the buttons where you want

    <input type="button" value="button name" onclick="window.open('http://www.website.com/page')" />


    Palagrin
    Participant

    @palagrin

    But that’s using the shortcodes and creating dedicated pages in WP right?

    I want BBP to automatically generate these pages, eg. https://mywebsite.blog/forums/login

    Pages required would be:
    – login
    – register
    – password reset
    – new topic
    – new reply

    My understanding of the shortcode is that if I wanted a new topic page, I would either have to have a generic one for the whole board or I would have to create individual ones for each forum based on the forum ID.

    The solution I’m looking for is for BBP to dynamically generate them as required. Is that possible?

    It seems odd to me that BBP doesn’t already do this.

    EDIT: would something along these lines work? https://stackoverflow.com/questions/32314278/how-to-create-a-new-wordpress-page-programmatically


    Palagrin
    Participant

    @palagrin

    To add to my answer, for example BBP already appears to do this with users – ie. it creates pages based on site.com/forums/users/username


    Robin W
    Moderator

    @robin-w

    The solution I’m looking for is for BBP to dynamically generate them as required. Is that possible?

    not within the current product.

    I’m not quite sure what you have against creating 5 pages yourself 🙂 🙂


    Palagrin
    Participant

    @palagrin

    Surely it can be done with a function? The plug-in must already be generating pages for the index, user profiles etc. Could creating a function create a page dynamically?

    Obviously it is “just” 5 pages but for larger forums it seems a little absurd to have to create identical “new topic” pages for each one!


    Robin W
    Moderator

    @robin-w

    anything can be done if you can find someone with the technical skills and time and are willing to pay the money for them to do the work !!

    The plugin does not generate WordPress ‘pages’ as such, it uses a theme’s template and renders data within that.

    I’m just a bbpress user who helps out on this forum, but if we ignore login, register and password reset which users may or may not want as pages (many use sidebar widgets and a multitude of membership plugins and methods to handle registration etc.) then I’m not clear what you want to happen with topic and reply forms – what is missing that you want that needs multiple forms?


    Palagrin
    Participant

    @palagrin

    That’s exactly what I want – I WANT it to use the template files!

    Whilst I can use the short code bbp-new-reply for example, it needs a topic ID to work. I simply don’t understand why BBP core doesn’t generate these pages programmatically – it makes absolutely no sense to me. You would think that would be basic functionality for a forum plugin!


    Palagrin
    Participant

    @palagrin

    Interestingly, when you click ‘edit’ on a reply it takes you to a new page where you can edit the reply. So somehow that should be possible to generate a NEW reply.


    Robin W
    Moderator

    @robin-w

    the topic and reply forms are at the bottom of the forum and topic pages, so there is no need to visit a separate page.

    I agree that this is far from obvious.

    my style pack plugin adds a button which takes you there

    bbp style pack

    once activated go to

    dashboard>settings>bbp style pack>Buttons

    I’m looking at creating a pop-up topic and reply form at the moment, but this is very much work in progress. If I succeed I’ll try and remember to post back here


    Palagrin
    Participant

    @palagrin

    the topic and reply forms are at the bottom of the forum and topic pages, so there is no need to visit a separate page.

    Well, yes, but it would be neat to have the option.

    I already link to the bottom of the page form via the html anchor – I’ve coded that into my theme – but I’m trying to have these forms on separate pages entirely, to make the whole thing a bit neater.


    Palagrin
    Participant

    @palagrin

    I’ve just noticed that BBP also generates a dedicated search page. Will have a dig and see how that’s done.


    Robin W
    Moderator

    @robin-w

    ok, so create a new topic form template

    find
    wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php

    transfer this to your pc and edit

    change around line 199

    <?php if ( ! bbp_is_single_forum() ) : ?>

    to

    <?php if (isset($_REQUEST['bbp_forum_id'])) : ?>
    <input type="hidden" name="bbp_forum_id" value="<?php echo $_REQUEST['bbp_forum_id']; ?>" />
    <?php elseif ( ! bbp_is_single_forum() ) : ?>

    and save

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/form-topic.php

    bbPress will now use this template instead of the original

    then put this in your child theme functions file

    add_action ( 'bbp_template_before_single_forum', 'reww_new_topic_button' ) ;
    
    function reww_new_topic_button () {
    	$url = $url = get_home_url(); 
    	$forum_id = bbp_get_forum_id() ;
    	$url.='/topic-form/?bbp_forum_id='.$forum_id ;
    	$text = 'create new topicc' ;
    	echo '<a class="hello" href ="'.$url.'">'.$text.'</a>' ;
    }
    

    where ‘/topic-form/’ is the page you have the topic form on

    that sends a query string to the topic form page, which is then picked up by the amended template above


    Robin W
    Moderator

    @robin-w

    you can then apply the same technique to the reply form

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