Forum Replies Created
-
In reply to: Displayname check
Check for an extra line or space after the closing
?>
tag, seems to be a common problem copying from the forums. Or an extra line or space before the<?php
tag.In reply to: open link within replys in a new windowArgh it ate part of it. Check the link and copy the line opening
$text
from there instead. There’s meant to be $1 in-between the spaces beforetarget
.In reply to: Displayname check<?php
/*
Plugin Name: No Duplicate Display Names
Description: Prevents users from using already existing display names.
*/
function check_display_name ( $user_id ) {
global $bbdb, $bb_current_id, $display_name;
$name_query = <<<EOQ
SELECT
user_login
FROM
$bbdb->users
WHERE
display_name = "$display_name"
AND
ID != "$bb_current_id"
EOQ;
if ( $name_clash = $bbdb->get_var( $name_query ) ) {
wp_redirect( add_query_arg( 'nameclash', $name_clash, get_user_profile_link( $user->ID ) ) );
exit;
}
}
add_action ( 'before_profile_edited', 'check_display_name' );
?>You also need in your theme’s profile.php, before the line <?php elseif ( $user_id == bb_get_current_user_info( ‘id’ ) ) : ?>
<?php elseif ( $_GET['nameclash'] ) : ?>
<div class="notice error">
<p><?php printf(__('Display name already taken by %s'), $_GET['nameclash' ]); ?>. <a href="<?php profile_tab_link( $user_id, 'edit' ); ?>"><?php _e('Edit again »'); ?></a></p>
</div>Also, I just set my display name to a SQL query string, yay
In reply to: Displayname checkMostly managed to write something, need to work on the error page though.
In reply to: Directly to latest post of Topic<?php $last_post = bb_get_last_post(); ?><a href="<?php echo get_post_link($last_post->post_id); ?>">Latest post</a><?php unset($last_post); ?>
Put that in your
front-page.php
in the parts you want the latest post link to appear. Try after<?php topic_page_links(); ?>
In reply to: Displayname checkYou could use this: https://bbpress.org/plugins/topic/disable-display-name/
In reply to: threaded forum ?A threaded forum layout could be achieved using a template, you’d just have to code it yourself by loading the titles from each thread (and add titles, either yourself or with a plugin) or find someone who has already done it. Why isn’t bbPress like that? It’s made to be as simple as possible so you can build what you want from it.
In reply to: Admin link doesn't take me to dashboardNope, that’s to fix your capabilities setting, without which I think it’d be impossible to access admin ever. Ah well
In reply to: No Analytics for AdminsHostnames will just be the public-facing DNS entry for your IP, which in my case at least is just a nice text-and-numbers version of my IP
In reply to: bbpress.org/forums statusMine was to check the bug tracker… oh dear
In reply to: bbpress.org/forums statusThe sky is falling!
In reply to: Number of Topics on BBpress.orgIt was like that pre-downtime, it’s just an odd quirk really.
In reply to: Memberlist Plugin page not foundThat is a point. Files with
.
in front of them are the equivalent in Linux/Unix of hidden files under Windows.In reply to: Memberlist Plugin page not foundbbPress’ base directory, not a dumb question
In reply to: Memberlist Plugin page not foundYou should have a line something like
RewriteRule ^mlist/ /mlist.php [L,QSA]
in your.htaccess
. Put it afterRewriteRule ^rss/view/([^/]+)/?$ /rss.php?view=$1 [L,QSA]
if you don’t.In reply to: Memberlist Plugin page not foundCould you post the link that’s failing and a link to the plugin you’re using?
In reply to: Moving the forum title without moving the tagline.Okay. In your stylesheet, put:
#title { position: absolute; top: 0px; }
#tagline { position: absolute; top: 75px; }I think that should work.
In reply to: Installing bbPressNo, it’s a directory, it’s just <your website>/<directory name>. You can put /index.php after if you want though.
In reply to: open link within replys in a new window<?php
/*
Plugin Name: Open Links in New Window
*/
function bb_target_blank( $text ) {
$text = preg_replace('|<a (.+?)>|i', '<a $1 target="_blank">', $text);
return $text;
}
add_filter('post_text', 'bb_target_blank',255);
?>Put the above into a file and save it as
new-window-links.php
or similar in yourmy-plugins
directory. Then enable it in the plugins menu. Should work. Avoid getting any spaces around the start and end tags.In reply to: Lack of bbsync means I might go with SMFhttps://bbpress.org/plugins/topic/wordpress-bbpress-syncronization
There we go. Working sync plugin afaik.
In reply to: Moving the forum title without moving the tagline.I think he’s trying to move the “PolyPowWow” bit above the tagline that’s positioned under it at the moment. I can’t for the life of me work out the CSS to do it either.
In reply to: removing raquo/or » from breadcrumbProgrammer’s Notepad + Find in Files = easy finding
In reply to: removing raquo/or » from breadcrumbApart from the template files
forum.php
andtopic.php
that use thebb_forum_bread_crumb()
(which just builds the breadcrumb for forums / topics), the separator is also hardcoded into several (all?) other template files to give custom titles, which I’m afraid have to be changed by hand.The only central location would be the default of
bb_forum_bread_crumb()
, which you shouldn’t change.In reply to: Not simple, fast or elegantAs delayedinsanity said, check your SQL server settings, namely by looking at the
wp-config.php
for WordPress and checking the database, username and password match. If you have a WordPress page named ‘forums’ and a directory called ‘forums’ that contains your bbPress forum, WP’s.htaccess
is set up to display the directory instead of the WP page. To make them look the same, you need to either use deep integration or modify your bbPress theme to look like WP’s.In reply to: Anyone Used bbPress Exporter 0.1a?bbPress Exporter 0.1a
exporter-bbpress.php
<?php
/*
Plugin Name: Export
Plugin URI: https://www.bbpress.org/
Description: Allows administrators to export forum data.
Author: Dan Larkin
Version: 0.1 alpha
Author URI: http://www.stealyourcarbon.net/
*/
/**
* Includes necessary files.
*/
function export_init ()
{
require_once ('wfxp.php');
require_once ('wfxp-bbpress.php');
}
/**
* Executes all necessary functions to make the exportation happen.
*/
function export_main ()
{
global $bbdb;
export_init ();
$bbxp = new WFXP_bbPress ($bbdb);
$bbxp->db = $bbdb;
$filename = 'bbpress' . date ('Y-m-d') . '.xml';
$bbxp->write_header ($filename);
$bbxp->write_users ();
$bbxp->write_forums ();
$bbxp->write_topics ();
$bbxp->write_footer ();
die ();
}
/**
* Displays the admin export page.
*
* Gives a simple explanation of how the export file works and gives
* users a nice shiny button to click.
*/
function export_page ()
{
?>
<div class="wrap">
<h2><?php _e ('Export') ?></h2>
<p><?php _e ('When you click the button below, bbPress will generate an XML file for you to save to your computer.'); ?></p>
<p><?php _e ('This file will contain data about your users, forums, topics, and posts. You can use the Import function of another bbPress installation or another compatible web forums software to import this data.'); ?></p>
<form action="" method="get">
<p class="submit">
<input type="submit" name="submit" value="<?php _e ('Download Export File'); ?>" />
<input type="hidden" name="exporting" value="true" />
</p>
</form>
</div>
<?php
}
/**
* Adds export link to admin menu.
*/
function export_add_admin ()
{
global $bb_submenu;
$bb_submenu['content.php'][] = array (__('Export'), 'use_keys', 'export_page', 'exporter-bbpress.php');
}
if ('true' == $_GET['exporting'] )
{
add_action ('bb_init', 'export_main');
}
add_action ('bb_admin_menu_generator', 'export_add_admin');
?>wfxp.php
<?php
/**
* Web Forums Data Export Class
*
* This class contains a number of functions used to take formatted
* input and output it into a standard XML file for use in transporting
* data between installations. Class extensions and plugins can be found
* for various software.
*/
class WFXP
{
/**
* Instance of BPDB.
*/
var $db;
/**
* Pseudonym for BPDB's get_results.
*
* This is a renaming of BPDB's get_results method to eliminate the need
* for the second parameter by always returning an associative array.
*/
function fetch ($query)
{
return $this->db->get_results ($query, 'ARRAY_A');
}
/**
* Adds formatted user data to the output.
*/
function add_user ($user)
{
?>
<user id="<?php echo $user['id']; ?>">
<login><?php echo $user['login']; ?></login>
<pass type="<?php echo $user['pass']['type']; ?>"><?php echo $user['pass']['pass'] ?></pass>
<incept><?php echo $user['incept']; ?></incept>
<status><?php echo $user['status']; ?></status>
<?php
if ($user['meta'])
{
foreach ($user['meta'] as $meta)
{
$this->add_meta ($meta, 'user');
}
}
?>
</user>
<?php
}
/**
* Adds formatted forum data to the output.
*/
function add_forum ($forum)
{
?>
<forum id="<?php echo $forum['id']; ?>" in="<?php echo $forum['in']; ?>">
<title><![CDATA[<?php echo $forum['title']; ?>]]></title>
<content><![CDATA[<?php echo $forum['content']; ?>]]></content>
<?php
if ($forum['meta'])
{
foreach ($forum['meta'] as $meta)
{
$this->add_meta ($meta, 'forum');
}
}
?>
</forum>
<?php
}
/**
* Adds formatted topic data to the output
*/
function add_topic ($topic)
{
?>
<topic id="<?php echo $topic['id']; ?>" author="<?php echo $topic['author']; ?>" in="<?php echo $topic['in']; ?>">
<title><![CDATA[<?php echo $topic['title']; ?>]]></title>
<incept><?php echo $topic['incept']; ?></incept>
<status><?php echo $topic['status']; ?></status>
<?php
if ($topic['meta'])
{
foreach ($topic['meta'] as $meta)
{
$this->add_meta ($meta, 'topic');
}
}
if ($topic['tags'])
{
foreach ($topic['tags'] as $tag)
{
$this->add_tag ($tag);
}
}
?>
<?php
foreach ($topic['posts'] as $post)
{
$this->add_post ($post);
}
?>
</topic>
<?php
}
/**
* Adds formatted post data to the output.
*/
function add_post ($post)
{
?>
<post id="<?php echo $post['id']; ?>" author="<?php echo $post['author']; ?>">
<title><![CDATA[<?php echo $post['title']; ?>]]></title>
<content><![CDATA[<?php echo $post['content']; ?>]]></content>
<incept><?php echo $post['incept']; ?></incept>
<status><?php echo $post['status']; ?></status>
<?php
if ($post['meta'])
{
foreach ($post['meta'] as $meta)
{
$this->add_meta ($meta, 'post');
}
}
?>
</post>
<?php
}
/**
* Adds formatted tag data to the output.
*/
function add_tag ($tag)
{
?>
<tag><![CDATA[<?php echo $tag; ?>]]></tag>
<?php
}
/**
* Adds formatted meta data to the output.
*
* Indentation varies depending on what type of element the meta data
* is being added to so as to make the output pretty.
*/
function add_meta ($meta, $type)
{
if ('post' == $type)
{
?>
<meta key="<?php echo $meta['key']; ?>"><![CDATA[<?php echo $meta['value']; ?>]]></meta>
<?php
}
else
{
?>
<meta key="<?php echo $meta['key']; ?>"><![CDATA[<?php echo $meta['value']; ?>]]></meta>
<?php
}
}
/**
* Writes file headers.
*
* Writes HTTP headers and adds the XML declaration as well as
* the top level container to the output.
*/
function write_header ($filename)
{
header ('Content-Description: File Transfer');
header ('Content-Dispositon: attachment; filename=' . $filename);
header ('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
?>
<forums_data>
<?php
}
/**
* Adds the closing tag for the top level container to the output.
*/
function write_footer ()
{
?>
</forums_data>
<?php
}
}
?>wfxp-bbpress.php
<?php
/**
* bbPress WFXP Extension
*
* This class includes functions necessary for bbPress to interface
* with the WFXP class, allowing for exportation of bbPress data to
* a standard XML file.
*/
class WFXP_bbPress extends WFXP
{
/**
* Fetches users from the database.
*/
function fetch_users ()
{
return $this->fetch ('SELECT * FROM ' . $this->db->users . ' WHERE 1');
}
/**
* Fetches forums from the database.
*/
function fetch_forums ()
{
return $this->fetch ('SELECT * FROM ' . $this->db->forums . ' WHERE 1');
}
/**
* Fetches topics from the database.
*/
function fetch_topics ()
{
return $this->fetch ('SELECT * FROM ' . $this->db->topics . ' WHERE 1');
}
/**
* Fetches posts from the database.
*/
function fetch_posts ($topic_id)
{
return $this->fetch ('SELECT * FROM ' . $this->db->posts . ' WHERE topic_id="' . $topic_id . '"');
}
/**
* Fetches user meta data from the database.
*/
function fetch_user_meta ($user_id)
{
return $this->fetch ('SELECT meta_key, meta_value FROM ' . $this->db->usermeta . ' WHERE user_id="' . $user_id . '"');
}
/**
* Fetches topic meta data from the database.
*/
function fetch_topic_meta ($topic_id)
{
return $this->fetch ('SELECT meta_key, meta_value FROM ' . $this->db->meta . ' WHERE object_type="bb_topic" AND object_id="' . $topic_id . '"');
}
/**
* Fetches topic tags from the database.
*
* Fetching topic tags requires multiple queries to
* determine the relationships between terms and IDs.
*/
function fetch_topic_tags ($topic_id)
{
$taxonomy_ids = $this->fetch ('SELECT term_taxonomy_id FROM ' . $this->db->term_relationships . ' WHERE object_id="' . $topic_id . '"');
if ($taxonomy_ids)
{
foreach ($taxonomy_ids as $taxonomy_id)
{
$term_id = $this->fetch ('SELECT term_id FROM ' . $this->db->term_taxonomy . ' WHERE term_taxonomy_id="' . $taxonomy_id['term_taxonomy_id'] . '"');
$tag = $this->fetch ('SELECT name FROM ' . $this->db->terms . ' WHERE term_id="' . $term_id[0]['term_id'] . '"');
$tags[] = $tag[0];
}
}
return $tags;
}
/**
* Prepares retrieved user data for output.
*/
function prep_user_data ($raw_user, $raw_meta)
{
$user['id'] = $raw_user['ID'];
$user['login'] = $raw_user['user_login'];
if (32 < strlen ($raw_user['user_pass']))
{
if (!strcmp (substr ($raw_user['user_pass'], 0, 4), '$P$B'))
{
$user['pass']['type'] = 'phpass';
}
else
{
$user['pass']['type'] = 'unknown';
}
}
else
{
$user['pass']['type'] = 'md5';
}
$user['pass']['pass'] = $raw_user['user_pass'];
$user['incept'] = $raw_user['user_registered'];
$user['status'] = $raw_user['user_status'];
$user['meta'][] = array ('key' => 'nicename', 'value' => $raw_user['user_nicename']);
$user['meta'][] = array ('key' => 'email', 'value' => $raw_user['user_email']);
$user['meta'][] = array ('key' => 'url', 'value' => $raw_user['user_url']);
$user['meta'][] = array ('key' => 'display_name', 'value' => $raw_user['display_name']);
if ($raw_meta)
{
foreach ($raw_meta as $raw_meta_entry)
{
$user['meta'][] = $this->prep_meta_data ($raw_meta_entry);
}
}
return $user;
}
/**
* Prepares retrieved forum data for output.
*/
function prep_forum_data ($raw_forum)
{
$forum['id'] = $raw_forum['forum_id'];
$forum['in'] = $raw_forum['forum_parent'];
$forum['title'] = $raw_forum['forum_name'];
$forum['content'] = $raw_forum['forum_desc'];
$forum['meta'][] = array ('key' => 'slug', 'value' => $raw_forum['forum_slug']);
$forum['meta'][] = array ('key' => 'order', 'value' => $raw_forum['forum_order']);
return $forum;
}
/**
* Prepares retrieved topic data for output.
*/
function prep_topic_data ($raw_topic, $raw_meta, $raw_tags, $raw_posts)
{
$topic['id'] = $raw_topic['topic_id'];
$topic['author'] = $raw_topic['topic_poster'];
$topic['in'] = $raw_topic['forum_id'];
$topic['title'] = $raw_topic['topic_title'];
$topic['incept'] = $raw_topic['topic_start_time'];
$topic['status'] = $raw_topic['topic_status'];
$topic['meta'][] = array ('key' => 'slug', 'value' => $raw_topic['topic_slug']);
$topic['meta'][] = array ('key' => 'open', 'value' => $raw_topic['topic_open']);
$topic['meta'][] = array ('key' => 'sticky', 'value' => $raw_topic['topic_sticky']);
if ($raw_meta)
{
foreach ($raw_meta as $raw_meta_entry)
{
$topic['meta'][] = $this->prep_meta_data ($raw_meta_entry);
}
}
if ($raw_tags)
{
foreach ($raw_tags as $raw_tag)
{
$topic['tags'][] = $this->prep_tag_data ($raw_tag);
}
}
foreach ($raw_posts as $raw_post)
{
$topic['posts'][] = $this->prep_post_data ($raw_post);
}
return $topic;
}
/**
* Prepares retrieved post data for output.
*/
function prep_post_data ($raw_post)
{
$post['id'] = $raw_post['post_id'];
$post['author'] = $raw_post['poster_id'];
$post['title'] = '';
$post['content'] = $raw_post['post_text'];
$post['incept'] = $raw_post['post_time'];
$post['status'] = $raw_post['post_status'];
$post['meta'][] = array ('key' => 'ip_address', 'value' => $raw_post['poster_ip']);
return $post;
}
/**
* Prepares retrieved tag data for output.
*/
function prep_tag_data ($raw_tag)
{
return $raw_tag['name'];
}
/**
* Prepares retrieved meta data for output.
*/
function prep_meta_data ($raw_meta)
{
return array ('key' => $raw_meta['meta_key'], 'value' => $raw_meta['meta_value']);
}
/**
* Fetches, prepares, and outputs user data using subroutines.
*/
function write_users ()
{
$users = $this->fetch_users ();
foreach ($users as $user)
{
$user_meta = $this->fetch_user_meta ($user['ID']);
$user = $this->prep_user_data ($user, $user_meta);
$this->add_user ($user);
}
}
/**
* Fetches, prepares, and outputs forum data using subroutines.
*/
function write_forums ()
{
$forums = $this->fetch_forums ();
foreach ($forums as $forum)
{
$forum = $this->prep_forum_data ($forum, $forum_meta);
$this->add_forum ($forum);
}
}
/**
* Fetches, prepares, and outputs topic data using subroutines.
*/
function write_topics ()
{
$topics = $this->fetch_topics ();
foreach ($topics as $topic)
{
$topic_meta = $this->fetch_topic_meta ($topic['topic_id']);
$topic_tags = $this->fetch_topic_tags ($topic['topic_id']);
$topic_posts = $this->fetch_posts ($topic['topic_id']);
$topic = $this->prep_topic_data ($topic, $topic_meta, $topic_tags, $topic_posts);
$this->add_topic ($topic);
}
}
}
?>It also has the Web Forum Export/Import Standard Validator, but I think this post is long enough already