Notifications
Clear all

[Closed] Shortcodes for Multi-boards

8 Posts
4 Users
1 Reactions
968 Views
Posts: 4
Topic starter
(@cloud9)
Active Member
Joined: 1 year ago

Use Case

I'm using LifertLMS to deliver training material for multiple courses, wpForo to facilitate discussion & Ultimate Member to show/hide blocks/content/pages. I have created separate boards for each course. The structure of each board is exacly the same including the IDs of each category and forum. For example the FAQ topic has the ID = 3 in each board. Each forum maps to a single lesson topic.

On each lesson page I want to include only the forum that is relevant to that lesson based on the course being viewed. So I use the shortcode system e.g.

[wpforo item="forum" id="3"]

If the user is on a page that is part of course 1 then I want the FAQ topic from board 1 to show. If the user is on a page from course 2 then I want the FAQ topic from board 2 to show.

Problem

According to the documentation, the shortcode doesn't have an option to specify the board so the forum with ID = 3 is always from the first board.

Question

How do I specify which board to source the requested forum from? If there is no current way to do this I'm happy to make a copy of the plugin and make temporary changes where indicated.

7 Replies
Posts: 4
Topic starter
(@cloud9)
Active Member
Joined: 1 year ago

I tried this in functions.php:

function set_wpForo_board() {
  if ( !is_admin() ) {
    // Only target the front end
    WPF()->change_board(2);
  }
}
add_action( 'the_post', 'set_wpForo_board');
 
The board ID changes but has no effect on the shortcode.
Posts: 4
Topic starter
(@cloud9)
Active Member
Joined: 1 year ago

The first part of the solution that seems to work is to progamtically change the board at the top of the wpforo theme's index page first making sure I'm on a lesson page (becasue the standalone pages work ok).

First copy the wpforo/themes/2022/index.php to my child theme at /my-child-theme/wpforo/index.php

Then insert the followig code after 

if( ! defined( 'ABSPATH' ) ) exit;
if ( is_singular( 'lesson' ) ) {
  global$post;
  $lesson = new LLMS_Lesson( $post->ID );
  if ( PROGRAM_2_COURSE_ID === $lesson->get( 'parent_course' ) ) {
    WPF()->change_board(PROGRAM_2_BOARD_ID);
  }
}
Please note however that this does not update all elements on the page. For example the permalinks are correct but the page title is not.
Posts: 4
Topic starter
(@cloud9)
Active Member
Joined: 1 year ago

The only way I've been able to get everything to work when using multiple boards and shortcodes is to modify function wpforo_url() in wpforo/includes/functions.php and call WPF()->change_board(2) there.

Is there an action or filter in Wordpress or wpForo that will allow the change in board to be reflected in the call to wpforo_url?

 
Chris
Posts: 3650
(@chris)
Famed Member
Joined: 3 years ago

Hi @cloud9,

About the shortcodes part, will try to fix that.

 

If you are using only one language in your Forum, I would recommend to Use Categories instead of board and Use wpForo Cross Posting addon to connect your Courses(Posts/Pages) with wpForo Topics.

WpForo Cross Posting addon has auto cross posting functionary. Which cross posts.

https://gvectors.com/product/wpforo-cross-posting/

3 Replies
(@steel-rat)
Joined: 3 years ago

Eminent Member
Posts: 29

@chris - Any update on adding board IDs to the shortcodes? I'm in the same boat as the OP, though I only have one additional board/forum.

(@steel-rat)
Joined: 3 years ago

Eminent Member
Posts: 29

Never mind. WPForo simply causes too many problems, even when it's the only activated plugin. Deleted.

dimalifragis
(@dimalifragis)
Joined: 4 years ago

Famed Member
Posts: 2614

@steel-rat wpForo doesn't cause ANY problems.

If you can't use it, it is not wpForo fault but of the webmaster.