Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of hnla

FAQ: How To, Code Snippets and Solutions (28 posts)

Started 2 years, 9 months ago by: Burt Adsit

  • Profile picture of Burt Adsit Burt Adsit said 2 years, 9 months ago:

    This topic is intended to be a forum resource to collect all the frequently asked questions and their answers. There are a lot of code snippets and how to answers floating around the forums. If you solve what you find is a common problem. Answer a question that seems to be asked frequently or have a small plugin or code snippet to contribute, then post it in this thread. I’ll include it in this post. This thread isn’t for conversations about such things. It’s for contributing what you find or create.

    Tools for developers:

    Firebug – http://getfirebug.com/ can’t live without it.
    Hooks and filters in wp utility – http://planetozh.com/blog/my-projects/wordpress-hooks-filter-flow/ this allows you to see all the functions that hook actions and filters in your bp site.

    Read this please and leave comments
    Buddypress.org needs a common place to share code snippets

  • Profile picture of Burt Adsit Burt Adsit said 2 years, 9 months ago:

    How to modify the buddypress admin bar:
    http://codex.buddypress.org/developer-docs/modifying-the-buddypress-admin-bar/
    http://buddypress.org/forums/topic.php?id=2186 >> forum topic for discussion

  • Profile picture of Burt Adsit Burt Adsit said 2 years, 9 months ago:

    How to restrict users to one blog per user:

    http://buddypress.org/forums/topic.php?id=1328

  • Profile picture of Burt Adsit Burt Adsit said 2 years, 9 months ago:

    Securing components from non logged in users:
    http://buddypress.org/forums/topic.php?id=1651 (older)

    http://buddypress.org/forums/topic/how-to-make-a-private-community#post-44616 (newer)

  • Profile picture of Burt Adsit Burt Adsit said 2 years, 9 months ago:

    How to upgrade to the trunk version of buddypress

    http://buddypress.org/forums/topic.php?id=2145

    You don’t have to use SVN if you don’t want to:

    http://buddypress.org/forums/topic.php?id=2171

    SVN is definitely the best way but not the only way.

  • Profile picture of Jeff Sayre Jeff Sayre said 2 years, 9 months ago:

    Having problems uploading an avatar? Do they turn black? Do they not show up at all? Does the cropping tool malfunction?

    http://buddypress.org/forums/topic.php?id=302#post-1212

    http://buddypress.org/forums/topic.php?id=1960#post-10404

    Some good advice on how to change blogs.dir directory permissions: http://buddypress.org/forums/topic.php?id=1153

    Here is a rule of thumb. You do not want to try uploading too big or too small of an avatar file. By default, BuddyPress sets the small avatar at 50 by 50 and the large avatar at 150 by 150. So, if your source image is smaller than 150 on at least one of its dimensions, you could have issues with creating the large avatar. If it is smaller than 50 on at least one of its dimensions, you could have issues with creating the small and large avatar.

    Finally, if you are still having issues after following the linked advice, you may have a WPMU plugin conflict–especially if you are using any plugins for image manipulation or display. Here is a list of plugins that can cause conflicts that users have reported to date:

    NextGen Gallery
    WP-cycle
    lightbox
    Dynamic Content Gallery

    To figure out if you have plugin issues, follow the standard WPMU protocol for determining plugin conflicts.

  • Profile picture of Burt Adsit Burt Adsit said 2 years, 9 months ago:

    Limiting the creation of blogs to certain user roles such as Site Admin

    This thread describes how to modify the both the admin bar and the member theme navigation functions using bp-custom.php. No core mods needed. It can give you an idea of how to modify any bp function that responds to an action.

    http://buddypress.org/forums/topic.php?id=2283

  • Profile picture of Vsellis vsellis said 2 years, 9 months ago:

    How to show secondary profile fields while hiding the ”Base” profile fields in a user profile:

    On line 3 of profile-loop.php add:<?php if (!bp_the_profile_group() == "1") : ?>
    (after the <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>)
    and don’t forget to close your ”if” before the <? endwhile; ?>

  • Profile picture of John James Jacoby John James Jacoby said 2 years, 5 months ago:

    Make your own custom BuddyPress page, slug, and template file

    http://buddypress.org/forums/topic/make-your-own-custom-buddypress-page

  • Profile picture of John James Jacoby John James Jacoby said 2 years, 3 months ago:

    Group/User Avatar Mix-up (usually after update/upgrade)

    http://buddypress.org/forums/topic/surprising-avatar-behavior?view=all#post-24791

  • Profile picture of Michael Berra Michael Berra said 2 years ago:

    I once posted a forum article about having profile information in the registration-mail to the admin, when a new member registers. We couldn’t accomplish that, but a friend of mine made it possible to have a direct link to the members-profile. That’s one click away and helps me very much, so that I don’t have to search for them. Here is the code, just put it in a php-file and in the mu-plugins folder:

    <?php
    /*
    Plugin Name: My Register Form
    Description: Customisations for the Registration Form
    Version: 0.1
    Author: Marc Cawood
    */
    
    // Custom Message in Registration Mail
    add_filter( 'newuser_notify_siteadmin', 'my_newuser_notify_siteadmin');
    
    function my_newuser_notify_siteadmin($msg) {
     global $current_site;
     // Extract member name
     $member = substring_between($msg, ': ', "n");
     // Link to member profile
     $member_url = clean_url("http://{$current_site->domain}{$current_site->path}members/".$member."/profile");
     return $msg . "nn" . $member_url;
    }
    
    function substring_between($haystack,$start,$end) {
     $start_position = strpos($haystack,$start)+strlen($start);
     $end_position = strpos($haystack,$end);
     return substr($haystack,$start_position,$end_position-$start_position);
    }
    
    ?>
  • Profile picture of Nick Watson Nick Watson said 2 years ago:

    Email Login & Randomized User URLs

    check out the following link for the solution:

    http://buddypress.org/forums/topic/email-login-randomized-user-urls-solution

    When a user goes to register, they get to type in an email and a password.
    Their ‘username’ field is hidden.

    The code will randomly generate a URL for the person like below:

    mem12345abcdefghijklmnopqrst

    so their URL would be

    http://www.yoursite.com/members/mem12345abcdefghijklmnopqrst

    Freeing up the good names like John and Smith to be created manually by an administrator.

  • Profile picture of Mike Pratt Mike Pratt said 2 years ago:

    It’s a great idea but just remember that the member directory, as it works now, alphabetizes by username so you will render that useless…for now

  • Profile picture of Nick Watson Nick Watson said 2 years ago:

    The member directory alphabetizes by the ”Name” field, which is a mandatory profile field defaulted by buddypress. So the only place that the username is really displayed and used is in the url.

  • Profile picture of Mike Pratt Mike Pratt said 2 years ago:

    @nickbwatson Duh. You’re right. I head my head somewhere else. What I meant to say was it screws up the new Mention feature which makes use of the @username model.