BBP function to automatically make forms on separate pages?
-
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?
-
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.
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?
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')" />
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 replyMy 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
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
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 🙂 🙂
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!
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?
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!
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.
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
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
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.
I’ve just noticed that BBP also generates a dedicated search page. Will have a dig and see how that’s done.
ok, so create a new topic form template
find
wp-content/plugins/bbpress/templates/default/bbpress/form-topic.phptransfer 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%/bbpresswhere %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.phpbbPress 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
you can then apply the same technique to the reply form
- You must be logged in to reply to this topic.