Bowe Codes, 10 shortcodes BuddyPress !

Il y a une semaine de cela @BoweFrankema me contacte par twitter pour me demander si je peux développer ce que lui a imaginé dans son esprit :

un nouveau plugin qui permette de très simplement ajouter des contenus BuddyPress dans des articles de blog, au sein d’un widget de type texte ou directement depuis des templates du thème.

L’idée me parait assez rapidement intéressante, et après quelques échanges de mail, nous travaillons tous les deux sur le sujet. Pour cela un simple dossier dropbox partagé entre nous deux aura suffit à nous permettre de développer la bête.

Le résultat !

Après avoir installé l’extension, vous verrez un nouveau bouton au dessus de votre éditeur. Si vous cliquez dessus, vous découvrirez la liste des 10 shortcodes disponibles :

L’éditeur de Bowe codes!

Par défaut, une feuille de style est chargée, si vous souhaitez ajouter vos propres styles, en allant sur l’administration BuddyPress, sous menu Bcodes Options, vous pouvez désactiver la feuille de style par défaut et vous inspirer d’elle pour définir vos propres styles. En effet un textarea affiche son contenu.

L’interface d’administration de Bowe codes

L’avantage d’utiliser l’API shortcodes de WordPress est que vous pouvez également rapidement créer vos propres widgets en vous basant sur le widget texte puis en insérant le shortcode de votre choix.
Ensuite depuis le functions.php de votre thème, vous n’avez plus qu’à ajouter 2 lignes de codes pour que les shortcodes soient joués dans vos widgets text

add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');

Un autre avantage est que vous pouvez également appeler les shortcodes depuis vos templates en utilisant la fonction suivante :

do_shortcode('[bc_friends dynamic="1"]');

J’ai également laissé la possibilité d’utiliser directement des tags pour ce dernier cas de figure, je laisse aux aventuriers du code source le soin de les trouver 😉 .

Pour terminer, voici une illustration de quelques Bowe Codes

Illustration de certains Bowe codes

le 11/11/2011 : version 1.1

  • Application des modifications css voulues par Bowe
  • Ajout de la possibilité pour un super admin de masquer le bouton BCodes aux sites enfants
  • Correction du bug apparu suite à l’upgrade 1.5 de BuddyPress sur le shortcode bc_friends

le 23/06/2012 : version 1.2

  • 2 nouveaux shortcodes : 1 pour réserver du contenu au sein d’articles et de pages aux membres d’un groupe, l’autre pour afficher les dernières entrées de forum.

le 16/09/2012 : version 1.3

  • un nouveau shortcode pour lister les membres d’un groupe en particulier.

66 commentaires sur “Bowe Codes, 10 shortcodes BuddyPress !

  1. Awesome plugin!

    I can display groups from my main blog on a network blog.

    The thing is, the links, point to the networkblog.com/groups/xxx

    not mainblog.com/groups/xxx

    So when you click on it you fail.

    I am using donncha domain mapping and the networkblog is domain mapped…

    Is this the issue? How can we fix?

    I am also super interested if you can display the group avatar and working link – then display the group activity next to it… i want to integrate more social features of buddypress to the network blogs…

    Thanks so much for a sik plugin. Thanks to Bowe for dreaming it up too !

    Johnny

  2. Hi Johnny,

    Thks for your comment, you can try to edit bowe-codes.php at line 34 by replacing :
    $group_home = $bp->root_domain.’/’.BP_GROUPS_SLUG.’/’.$slug.’/’;
    by $group_home = ‘http://mainblog.com/‘.BP_GROUPS_SLUG.’/’.$slug.’/’;

    Concerning your request (display group activity), i keep the suggestion for maybe a new shortcode 😉

  3. Hi

    The change the root fix worked perfectly – thank you.

    At the bottom of http://surfboardsale.com.au you can see its implementation.

    However, now I have another issue.

    I use Group Hierarchy – is there a basic slug to link to that would redirect to the correct group?

    I understand if you did not want to support using other plugins.

    I’ll appreciate any help I could get.

    Cheers

    John

    1. Ok this is what i tested and it seems to work :

      still in line 34 of bowe-codes.php, replace for something like the following :
      $group_home = bp_group_hierarchy_fixup_permalink(‘http://mainblog.com/‘.BP_GROUPS_SLUG.’/’.$slug.’/’);

  4. Hi,

    great plugin so far!
    But I ahve a question, is it possible with your plugin to create a widget which shows every 5 min a different avatar of a user with the name of the user.
    Like a « Frame of Fame »…
    If so, how?

    Thank you very much in advance!

    Marc

  5. Hi Marc,

    i guess it’s possible, but you’ll have to create your shortcode or play with jQuery to do so.

    If i were you i’ll add a shortcode on the model of the bc_members one. then instead of sending directly the html, i would store members in an array and make a rand on

    Using jQuery you can also make li elements slide… Maybe you can find a great help on BP Tricks on this one 😉
    http://bp-tricks.com/featured/buddypress-shortcodes-plugin/

  6. Bonjour Imath,

    Je suis en train de tester votre tool et je ne trouve pas encore ce que j’ai besoin. En fait, je voudrais pouvoir inserer le contenu d’un champ du profile dans un post.

    Est-ce possible avec votre tool?

    Merci d’avance

    Bien à vous

    Anner

  7. Salut Anner,

    un des shortcode permet d’afficher un ou plusieurs xprofile field à partir du moment où le login de l’utilisateur est renseigné, ex :
    [bc_member name= »imath » fields= »Fonction »]

    dans fields, il est possible de mettre une liste des champs séparés par des virgules.

    Autrement, vous pouvez aussi très simplement faire :
    <?php echo xprofile_get_field_data( ‘Fonction’, $user_id );?> et remplacer $user_id par l’id du membre désiré..

    PS: pour l’auteur d’un post > $user_id = get_the_author_id();

    1. Bonjour imath merci pour ce que vous faites pour la communauté Buddy Press que je viens de découvrir (et l’outil et la communauté). J’ai créé des goupes qui correspondent aux 13 nouvelles régions de France.
      Au niveau du profil utilisateur je leur propose de cocher de façon obligatoire leur statut, soit : participant, association ou entreprise.
      Pensez vous qu’il est possible de créer un short code qui filtre par groupe (région) mais aussi par style de membre ? members_association, et comment l’utiliser via votre pluggin.
      Merci
      Béatrice

      1. Hello Béatrice,
        Merci à vous pour votre intérêt pour BuddyPress. Cela fait un moment que je n’ai pas regardé ce plugin. Il me semble qu’il y avait une API pour créer ses propres shortcodes/widgets..
        Pour répondre à votre question, oui, je pense qu’à partir du moment où ce sont des membres de groupes qui ont spécifié leur type de membre alors on peut « filtrer » en ce sens, l’API pour afficher les membres d’un groupe étant une extension de celle qui affiche les membres.

  8. Hello,
    first of all thanks for this great plugin.

    I would like to request a feature.
    Sometimes I ask users to enter a list of items, but whenever I call it with Bowe_Codes in a post, it comes out list this:

    List of items: Array

    Instead of

    List of items:
    – Item one
    – Item two
    – Item three

    I would like it come out the list of the items, and each item on a separte line.

    Thank you in advance.

  9. Hello gixty,

    Thank you for your comment. I try to understand.. What is the shortcode concerned ? Are you talking about xprofile fields you want to show ?

  10. let’s see how I can explain this. English is not my first language.

    I am using GravityForms plugin and xprofile fields.
    At registration, I use Gravityforms and have users fill out some fields. One the fields is a list of item. Gravityforms has an option where users can input a « list »

    Then, buddypress registers this list using the xprofile fields as a multiline text form. And it displays it in the user’s profile page as various items separated by comas.

    When I use Bowe_codes to call this multiline text list of items, Bowe_codes show only the word « Ärray » instead of showing the list of items.

    Thus, I would love if Bowe_codes could display the list of items. Each item in a separated line or by comas, depending on the options.

    I hope I am making myself clear. If not, I will find another way to explain it.

    Once again, thank you for the plugin.

    Another thing, Can I display a list of images from the users album?

  11. Gixty,

    you’ll have to edit bowe-codes.php.. you can try to replace the foreach statement of lines 107 to 109 by this one :

    foreach($parse_fields as $user_xprofile){
    $member_data = xprofile_get_field_data( $user_xprofile, $user_id );
    if(is_array($member_data)) $member_data = '<ul><li>' . implode( '</li><li>' , $member_data ) .'</li></ul>' ;
    $member_html .= '<p><span class="xprofile_thead">'.$user_xprofile.'</span><span class="xprofile_content">'.$member_data.'</p>';
    }

    I cannot help you more on this one / or garanty it’ll work as you’re using a specific plugin.

  12. Great! I will try that and see if it works.
    However, I dont think Gravityforms has to do anything with it. As xprofile and buddypress are the ones who are handling the form input/output.

    I hope you are still developing this great plugin and adding more functionalities. For example, I had to modify some pieces of code so the name of the user would not come out every time I call the function.

  13. Hi again,

    now, what If I want to pull the data from a non array field. The user just input a list of items in a multi line text field. The user inserted each item in a new line.

    I want to display it as is. Each item in a new line.

    This one is different as before because it is not using an array.

  14. oh I see what is happening. Forget what I said in last post.

    Everything is working fine as long as the user keeps the comas. However, if the user removes the comas and puts each item on a new line, the bowe_code outputs like this:

    item1 item2 item3 item4

    it should keep the format and output it like this:

    item1
    item2
    item3
    item4

    I know this is very basic stuff, but it is messing up my head.

  15. in MySQL, the table bp_xprofile_fields has the row:
    type: « textarea »
    name: « Lista de Empresario »

    is that what you asked for?

  16. Hello again!

    I just noticed that if you use bowe-code between shortcode tags, the items wont have break lines. I tried using do_shortcode($member_html); but it didnt work. Everything is still on the same line.

    What could I do to fix this little thing?

  17. hehe sorry for not explaining well..

    remember you told me to use:
    « try to replace $member_data by nl2br($member_data) in $member_html… »

    That works fine as long as I dont put any bowe code between shortcode tags.

  18. This is what I am using:

    this works excellente:
    [bc_member name= »**** » avatar= »0″ fields= »**** »]

    but if I put it inside a shortcode like this:
    [learn_more caption= »**** »]
    [bc_member name= »**** » avatar= »0″ fields= »**** »]
    [/learn_more]

    the break lines disappear. All the items appear in one line.

    It happens with any shortcode I use.

  19. Hi Imath,

    This plugin works really well. There is one thing I do not find a solution for and that is that fielddnumber and Name ID are displayed aswell which I do not want. I only want to have displayed the content of the fields not the field-description with it. Is there a way too do that?

    Now I have:

    118645 (=Name)

    2 (= Fild ID) Innside by Melià Berlin (BP)

    I just want to have :

    Innside by Melià Berlin (BP)

    Without links aswell.

    Would you have a tip for that?

    Thanks in advance

    Best regards,

    Anner

  20. Hi Anner,

    You do not want to have for instance :

    Interest: BuddyPress

    but only BuddyPress

    Maybe you can try a css trick :


    div.user-infos span.xprofile_thead {display:none!important}

    Thanks for your feedback and comment 😉

  21. Hi

    Still after short codes to do this following:

    Display current user avatar, link to bp profile.

    Also, trying to get current users ‘achievements’ and ‘cube points’ via short code too !

    I am doing all this on a page, so I can’t use PHP.

    Any ideas on a quick fix?

    Cheers,

    Johnny

  22. hi

    is there any documentation on what exactly are the short codes because we don’t seem to be getting the bowe codes to dispay all the options in our editor.

    rgds
    shawn

  23. Hi @ Shawn,

    I think the editor displays all the options. But just in case here’s a simple documentation :

    [bc_member avatar="1 for true, 0 for false" size="50" name="login_of_the_member_to_show" class="default to my_member" fields="comma separated list of the xprofile fields you want to show"]

    [bc_group avatar="1 for true, 0 for false" size="50" slug="the slug of the group you want to show" class="default to my_group" desc ="1 to show group description"]

    [bc_groups amount="number of groups to show" avatar="1 for true, 0 for false" size ="50" type="popular, active or newest" featured ="comma separated list of group slugs you want to feature" class ="default to my_groups"]

    [bc_members amount="number of members to show" avatar="1 for true, 0 for false" size ="50" type="active or newest" featured ="comma separated list of member logins you want to feature" class="default to my_members"]

    [bc_friends amount="number of friends to show" avatar="1 for true, 0 for false" size ="50" type="active or newest" class="default to my_friends" dynamic="1 to show the friends of displayed user, 0 to remain on those of loggedin user"]

    [bc_user_groups amount="number of users to show" avatar="1 for true, 0 for false" size ="50" type="popular, active or newest" class="default to user_groups" dynamic="1 to show the groups of displayed user, 0 to remain on those of loggedin user"]

    [bc_messages amount="number of messages to show" subject="1 to show, 0 to hide the subject" avatar="1 for true, 0 for false" size="30" excerpt="length of the excerpt in number of words" class="default to my_messages"]

    [bc_notifications amount="number of notifications to show" avatar="1 for true, 0 for false" size="30" class="default to my_notifications"]

    [bc_blogs amount="number of blogs to show" avatar="1 for true, 0 for false" size="50" type="active or newest" featured ="comma separated list of blog ids you want to feature" class="default to my_blogs" desc ="1 to show blog description"]

    [bc_posts amount="number of posts to show" avatar="1 for true, 0 for false" size="50" type="random or newest" class="default to my_blog_posts" excerpt="length of the excerpt in number of words"]

  24. Bonjour,

    En test de la version beta 1.6 de buddypress, je voulais tester en plus justement ce petit plugin fort interessant pour une home page. Cependant lors du clic dans l’éditeur visuel sur le bouton BP Codes, la page d’édition des shortcodes reste vide.

    Hum… une idée?

    1. Salut @ CC

      Ce n’est pas lié à la 1.6beta1. Je viens de tester, je n’ai constaté aucune difficulté. Je pense que c’est lié au chargement du bootsrap WordPress de la page d’édition des shortcodes. Je te propose de m’aider à débugger cette difficulté. Pourrais-tu éditer le fichier /wp-content/plugins/bowe-codes/includes/bowe-codes-editor.php en remplaçant les lignes 3 à 34 par ce code :

      $admin = dirname( __FILE__ ) ;
      $admin = substr( $admin , 0 , strpos( $admin , 'wp-content' ) ) ;

      if( file_exists( $admin . 'wp-load.php' ) )
        require_once( $admin . 'wp-load.php' ) ;
      else
        require_once( $admin . 'wp-config.php' ) ;

      Si cela résout la difficulté, je ferais un upgrade du plugin ce week-end.
      Merci de ton aide.

  25. Malheureusement cela ne change pas grand chose, néanmoins la cause insolite à été trouvée, il se trouve qu’il s’agit de l’extension Contact Form 7 qui réalise ce bug d’affichage. Je ne vois pas trop le lien entre les deux pourtant.

    Du coup en désactivant Contact Form 7, aucun problème, concernant tes modifications de codes, aucun soucis constatés.

    Voila^^

  26. Hi,

    Thank you very much for this such Wonderful Plugin, i have used bowe codes because it is good.

    One question is:

    How could i used or is there any way we can pull out members from a certain group?

    Like if we have group « Katz » Only show members from this group?

    thanks

    Regards,
    Vince

    1. Hi @ Welvin

      Thanks for your comment and interest in this plugin. This is a very good idea !! I’ll check tonight what i can do and depending on the complexity post a trick to achieve it or build an upgrade in repo 😉

  27. Hello imath

    Your plugin has helped me to show the posts in a page but i also want to show the pagination for the posts as the number of posts to be shown on the page are limited as per the filed provided in the shortcode.

    Can you pl help me?

    Regards
    Renu

    1. i’ll see what i can do. But to display the post this plugin uses the activities generated by BuddyPress.. The goal of it is to show latest blog posts not all blog posts. You may look for a plugin/widget that handle this behavior on WordPress.org.

    1. hi there !

      you mean : get all the group the user is member of and then display his activity in it ?
      Or for a given group display all its users activity ?

      bye.

  28. Hi imath,

    I came across your very nice plugin which I hope to use on my website, however my users’ use the WordPress text editor in the front-end UI due to another plugin (which references the editor through wp_editor() ) and I see that the BCodes icon appears to the right of ‘Add Media’. Is there a way to suppress this icon from displaying to the users please?

    Many thanks,
    Joanna

    1. Thanks for your comment and interest, i suggest you to try editing line 866 of bowe-codes.php by replacing it with
      if( bowe_codes_can_child_blogs() && is_admin() )

      It should prevent the bowe code btn to load while on frond end.

  29. Hi,
    Really like the idea of your plugin, but I’m looking for something that can display all blog posts in a time period (I want the posts from around the network from the last week), is that something you could add as a feature? Similar to your #items option for bc_posts, but then time-limited and not amount limited.

    Olaf

  30. Hello imath!

    Thanks for this great plugin 🙂

    Is there a possibility to sort the member list output of the following code by name/alphabetically?

    Thanks very much in advance!

Les commentaires sont fermés.