Fix bbPress Admin Access
January 15th, 2011 at 01:08pm Jason 236 views
This plugin is only meant as a simple way to fix roles for users doing reverse integration of bbPress with WordPress without having to resort to using phpMyAdmin but it may have other uses if a primary admin role gets corrupted or wiped out for some reason.
Restores keymaster access to control panel on bbPress and/or WordPress integration. This is an auto-load plugin and must have a leading underscore “_”. Put into your plugin directory, access bbPress and/or WordPress once and then delete it from the directory.
The Author created this after having to instruct two different people through phpMyAdmin to fix such a problem. For now it assumes the primary keymaster is user id #1. If not, which is rare but possible, it won’t fix the problem.
<?php /* Plugin Name: Fix Admin Access Description: restores keymaster access to control panel on bbPress and/or WordPress integration. This is an auto-load plugin and must have a leading underscore "_". Put into your plugin directory, access bbPress and/or WordPress once and then delete it from the directory. Plugin URI: http://bbpress.org/plugins/topic/86 Author: _ck_ Author URI: http://bbshowcase.org Version: 0.0.3 Instructions: This is an auto-load plugin and must have a leading underscore "_". Put into your plugin directory, access bbPress and/or WordPress once and then delete it from the directory. Warning: This plugin assumes your keymaster is user id #1. It is rare but possible you are no longer user #1 if you have deleted your original keymaster. In which case this won't work. */ function fix_admin_access() { $id=1; // assume keymaster was user #1, you can change this to another number if you are positive it's different global $bb,$bbdb,$wpdb; if (isset($bbdb)) {$db=$bbdb;} else {$db=$wpdb;} if (empty($bbdb->prefix)) {$prefix="bb_";} else {$prefix=$bbdb->prefix;} if (empty($bb->wp_table_prefix)) {$wp_prefix="wp_";} else {$wp_prefix=$bb->wp_table_prefix;} $meta=array( $prefix.'capabilities' => 'a:1:{s:9:"keymaster";b:1;}', $wp_prefix.'capabilities' => 'a:1:{s:13:"administrator";b:1;}', $wp_prefix.'user_level' => '10' ); if ($db) { foreach ($meta as $key => $value) : if ($db->get_var("SELECT meta_value FROM $db->usermeta WHERE meta_key = '$key' AND user_id = '$id' LIMIT 1")) {$db->query("UPDATE $db->usermeta SET meta_value = '$value' WHERE user_id = '$id' AND meta_key = '$key' LIMIT 1");} else {$db->query("INSERT INTO $db->usermeta (user_id, meta_key, meta_value) VALUES ('$id', '$key', '$value')");} endforeach; } } add_action('bb_init','fix_admin_access',200); add_action('init','fix_admin_access',200); ?>
Copy the codes above and save as _fix_admin_access.php.
Fix Admin Access: http://bbpress.org/plugins/topic/fix-admin-access/
Entry Filed under: WordPress Tagged with: bbpress PHP plugin wordpress
Hot Posts Hot Comments Hot Tags
- apartment bbpress blog class CMS code CSS div dream english friends girl Google hot Hot Dog html job JS life lines love Madonna menu Michael Jackson movie oral english PHP plugin saying school sexy site student students submenu success tags teacher teaching txt university video website widget wordpress





Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackback this post | Subscribe to the comments via RSS Feed