[buddypress-dev] Better way of doing this?

Martin martin at thrive-magazine.com
Thu Jun 19 16:30:03 GMT 2008


Motivated by seeing Andy's screen shots of the new theme he is working on I
have started work on my own BuddyPress compatible theme, but I have hit a
problem that I have managed to solve but it required a change in the core
Wordpress MU code, which I was trying to avoid if at all possible.

 

First some background, I am working on a website that is running Wordpress
MU in non virtual host mode, so the blogs are www.domainname.com/blogname,
and want to allow for a user being an administrator on multiple blogs, and a
blog to have multiple authors. I decided that I wanted
www.domainname.com/members/username to show a user profile and list their
blogs and www.domainname.com/profile to show the current user. First problem
is that because I am not configured as a virtual host Wordpress MU tries to
create a blog called members or profile, I have managed to solve this by
changing a line in wpmu-settings.php from

$blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes',
'wp-content', 'files', 'feed' );

To

$blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes',
'wp-content', 'files', 'feed', 'members', 'profile' ); 

 

Is there a better way of getting Wordpress MU to allow this to go through?

 

For those of you that may want to do the same thing I then modified my
.htaccess and added the following lines to it:

RewriteRule ^.*/?members/(.*)/ /index.php?sn_action=member&sn_member=$1 [L]

RewriteRule ^.*/?profile/$ /index.php?sn_action=profile [L]

 

I'm far from being a mod rewrite expert, so someone may be able to suggest a
better way of doing this?

 

I then wrote a plug-in that looks for sn_action and includes a page from the
current template to display the information e.g.

 function member_redirect() {

  if (isset($_GET['sn_action'])) {

        $action = $_GET['sn_action']; 

            switch($action) {

          case 'member':

        if (isset($_GET['sn_member'])) {

          $sn_member = $_GET['sn_member'];

          if($template = get_query_template('member')) {

            include($template);

            exit;

          }

        }

            exit;

          break;  

...<snip>

 

add_action('template_redirect', 'member_redirect');

 

Again I am no expert at this there may be a better way?

 

All that remains to be done is to add a member.php etc. to the home
template. You can then modify the default template to show all author
information for the blog, with links to their profiles, instead of trying to
figure out who's profile to show for the current blog.

 

It will also allow me to add template changes so that a user can "follow" a
blog, but be a "friend" to a user.

 

Another problem I see with this method is the member URL is formed using the
login name of the user, I really don't want to make that publically
viewable, is there a way currently, or going to be a way in the future that
I can create a required field in XProfile that should be unique across all
users, so a user can enter what they want to be used for their URL?

 

I love where BuddyPress is going, and have enjoyed working on my own theme
for it, if any one wants more information on what I'm doing, let me know,

 

Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://comox.textdrive.com/pipermail/buddypress-dev/attachments/20080619/cf085080/attachment.htm


More information about the buddypress-dev mailing list