Skip to content

Developer Guide

This page documents what the plugin stores and which hooks it wires into. It reflects the code as shipped.

The plugin does not currently register any of its own apply_filters / do_action extension points for third-party code. The integration points below are the WordPress, LearnDash and wpForo hooks it consumes, plus its custom table and the public PHP methods you can call.

The plugin creates one custom table, {$wpdb->prefix}ldwpforo_map:

Column Type Purpose
map_id BIGINT, PK, auto-increment Row id
forum_id BIGINT wpForo forum id
board_id BIGINT (default 0) wpForo board id; 0 = default board
course_id BIGINT LearnDash course id
access_mode VARCHAR(10) (default any) all or any
privacy VARCHAR(20) (default auto) auto, private, public_read, or public
usergroup_id BIGINT (default 0) wpForo usergroup created for the course
no_access_msg TEXT Custom no-access message
allow_forum_view TINYINT(1) (default 0) Read-only view for non-enrolled users
created_at / updated_at DATETIME Timestamps

Keys: unique on (forum_id, board_id, course_id); indexes on course_id, forum_id, usergroup_id.

The schema version is stored in the ldwpforo_db_version option and the table is (re)built automatically when that option does not match the plugin’s DB_VERSION.

Registered by LDWPF_Sync::init():

Hook Action taken
learndash_update_course_access Add/remove the user in the course usergroup for every mapping on that course
ld_added_group_access Add the user to the usergroups of every course the LearnDash group enrolls
ld_removed_group_access Reverse of the above
Hook Where Purpose
wpforo_clean_cache_start admin Save handlers for the forum-side settings box (default board and per-board)
wpforo_wpftpl public Swap the topic template to the no-access template when the user lacks access
wpforo_footer_hook public Remove the topic/reply form for users without access

These static methods are safe entry points for custom code:

  • LDWPF_Mapping_Repo::get_by_course( $course_id ), ::get_by_forum( $forum_id, $board_id ), ::get_all(), ::save_forum_mapping( $forum_id, $board_id, $course_ids, $settings ), ::delete_forum_mappings( $forum_id, $board_id ).
  • LDWPF_Sync::reconcile_forum( $forum_id, $board_id ) — rebuild one forum’s permissions and backfill enrollees.
  • LDWPF_Sync::reconcile_all() — reconcile every mapping. Not wired to any UI or CLI command; call it from your own code (for example a WP-CLI wp eval) if you need a full resync.
  • LDWPF_Privacy::resolve( $mapping ) — resolve a mapping’s effective privacy (private / public_read / public).
  • LDWPF_Wpforo_API::* — thin wrappers over wpForo’s forums, usergroups and profiles tables (set_forum_permissions, create_usergroup, add_user_to_group, remove_user_from_group, get_user_groups).

For backward compatibility the plugin mirrors each forum’s settings into an option: ld_forum_{forum_id} for the default board and ld_board_forum_{board_id}_{forum_id} for other boards. Front-end access checks fall back to these options when no mapping row exists (for example on a site mid-migration).