LLMS_Integration_BBPress::get_forum_course_restrictions( int $forum_id )
Check if a forum is restricted to a course(s)
Parameters Parameters
- $forum_id
-
(int) (Required) WP_Post ID of the forum.
Return Return
(int[])
Source Source
File: includes/integrations/class.llms.integration.bbpress.php
public function get_forum_course_restrictions( $forum_id ) { global $wpdb; $query = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->prepare( "SELECT metas.post_id FROM {$wpdb->postmeta} AS metas JOIN {$wpdb->posts} AS posts on posts.ID = metas.post_id WHERE metas.meta_key = '_llms_bbp_forum_ids' AND metas.meta_value REGEXP %s AND posts.post_status = 'publish';", 'a:[0-9][0-9]*:\{(i:[0-9][0-9]*;(i|s:[0-9][0-9]*):"?[0-9][0-9]*"?;)*(i:[0-9][0-9]*;(i|s:[0-9][0-9]*):"?' . sprintf( '%d', absint( $forum_id ) ) . '"?;)' ) ); $query = array_map( 'absint', $query ); return $query; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.0.0 | Escape { character in SQL query to add MySQL 8.0 support. |
3.38.1 | Make the query more generic so that it matches forum ids whether they've been saved as integers or strings. |
3.12.0 | Introduced. |