Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Integrate wp2.7 and bbp1.0a2


John James Jacoby
Keymaster

@johnjamesjacoby

Short term, I was able to make this work by modifying 1 core WordPress file. This only allows for integration of the theme, but still does not allow access to the bbPress admin panel without changing the bb-config.php file back to original.

It’s essentially a quick fix to get the theme working with all capabilities playing nicely.

Basically I’m hard-coding the capability check from bbPress into WordPress. There should be a filter for this, but I’m not sure how to hook into it correctly without a mod or plug-in on the WordPress side.

~My fix is in no way a permanent solution. Auto-updating your WordPress installation will overwrite this fix.~


In FILE wp-includes/capabilities.php:

In the meta_map_cap function:

Around Line 906:

AFTER break;

BEFORE default

INSERT:

/*

*/
case 'write_post':
$caps[] = 'write_posts';
break;
case 'edit_post':
// edit_posts, edit_others_posts, edit_deleted, edit_closed, ignore_edit_lock
if ( !$bb_post = bb_get_post( $args[0] ) ) {
$caps[] = 'magically_provide_data_given_bad_input';
return $caps;
}
if ( $user_id == $bb_post->poster_id )
$caps[] = 'edit_posts';
else
$caps[] = 'edit_others_posts';
if ( $bb_post->post_status == '1' )
$caps[] = 'edit_deleted';
if ( !topic_is_open( $bb_post->topic_id ) )
$caps[] = 'edit_closed';
$post_time = bb_gmtstrtotime( $bb_post->post_time );
$curr_time = time() + 1;
$edit_lock = bb_get_option( 'edit_lock' );
if ( $edit_lock >= 0 && $curr_time - $post_time > $edit_lock * 60 )
$caps[] = 'ignore_edit_lock';
break;
case 'delete_post' :
// edit_deleted, delete_posts
if ( !$bb_post = bb_get_post( $args[0] ) ) {
$caps[] = 'magically_provide_data_given_bad_input';
return $caps;
}
if ( 0 != $bb_post->post_status )
$caps[] = 'edit_deleted';
// NO BREAK
case 'manage_posts' : // back compat
$caps[] = 'delete_posts';
break;
case 'write_topic':
$caps[] = 'write_topics';
break;
case 'edit_topic':
// edit_closed, edit_deleted, edit_topics, edit_others_topics
if ( !$topic = get_topic( $args[0] ) ) {
$caps[] = 'magically_provide_data_given_bad_input';
return $caps;
}
if ( !topic_is_open( $args[0]) )
$caps[] = 'edit_closed';
if ( '1' == $topic->topic_status )
$caps[] = 'edit_deleted';
if ( $user_id == $topic->topic_poster )
$caps[] = 'edit_topics';
else
$caps[] = 'edit_others_topics';
break;
case 'move_topic' :
$caps[] = 'move_topics';
break;
case 'stick_topic' :
$caps[] = 'stick_topics';
break;
case 'close_topic' :
$caps[] = 'close_topics';
break;
case 'delete_topic' :
$caps[] = 'delete_topics';
add_filter( 'get_topic_where', 'no_where', 9999 );
if ( !$topic = get_topic( $args[0] ) ) {
$caps[] = 'magically_provide_data_given_bad_input';
return $caps;
}
if ( 0 != $topic->topic_status )
$caps[] = 'edit_deleted';
remove_filter( 'get_topic_where', 'no_where', 9999 );
break;
case 'manage_topics' :
// back compat
$caps[] = 'move_topics';
$caps[] = 'stick_topics';
$caps[] = 'close_topics';
$caps[] = 'delete_topics';
break;
case 'add_tag_to':
// edit_closed, edit_deleted, edit_tags;
if ( !$topic = get_topic( $args[0] ) ) {
$caps[] = 'magically_provide_data_given_bad_input';
return $caps;
}
if ( !topic_is_open( $topic->topic_id ) )
$caps[] = 'edit_closed';
if ( '1' == $topic->topic_status )
$caps[] = 'edit_deleted';
$caps[] = 'edit_tags';
break;
case 'edit_tag_by_on':
// edit_closed, edit_deleted, edit_tags, edit_others_tags
if ( !$topic = get_topic( $args[1] ) ) {
$caps[] = 'magically_provide_data_given_bad_input';
return $caps;
}
if ( !topic_is_open( $topic->topic_id ) )
$caps[] = 'edit_closed';
if ( '1' == $topic->topic_status )
$caps[] = 'edit_deleted';
if ( $user_id == $args[0] )
$caps[] = 'edit_tags';
else
$caps[] = 'edit_others_tags';
break;
case 'edit_user':
// edit_profile, edit_users;
if ( $user_id == $args[0] )
$caps[] = 'edit_profile';
else
$caps[] = 'edit_users';
break;
case 'edit_favorites_of':
// edit_favorites, edit_others_favorites;
if ( $user_id == $args[0] )
$caps[] = 'edit_favorites';
else
$caps[] = 'edit_others_favorites';
break;
case 'delete_forum':
$caps[] = 'delete_forums';
break;
case 'change_user_password':
// change_password, edit_users
$caps[] = 'change_password';
if ( $user_id != $args[0] )
$caps[] = 'edit_users';
break;
/*
*/

Skip to toolbar