Bowe Codes, 10 shortcodes BuddyPress !

Publié le

par

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 réponses à “Bowe Codes, 10 shortcodes BuddyPress !”

  1. Avatar de Johnny
    Johnny

    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. Avatar de imath

    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. Avatar de Johnny

    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. Avatar de imath

      As I dont know about this plugin… diving in it’s source code and will be back later on this 😉

    2. Avatar de imath

      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. Avatar de Marc

    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. Avatar de imath

    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. […] de tinyMCE ou à la mediabar juste au dessus. C’est ce que j’ai fait pour le plugin Bowe Codes. Dans cette extension, je voulais notamment intégrer un moyen de simplifier la rédaction du […]

  7. Avatar de Anner
    Anner

    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

  8. Avatar de imath

    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. Avatar de Donnard Béatrice
      Donnard Béatrice

      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. Avatar de imath

        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.

  9. Avatar de Anner
    Anner

    Cool! J’essayerais. Merci!

  10. Avatar de gixty
    gixty

    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.

  11. Avatar de imath

    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 ?

  12. Avatar de gixty
    gixty

    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?

  13. Avatar de imath

    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.

  14. Avatar de gixty
    gixty

    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.

  15. Avatar de gixty
    gixty

    Update: It worked!
    Thanks a lot =)

    1. Avatar de imath

      You’re welcome 😉

  16. Avatar de gixty
    gixty

    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.

  17. Avatar de gixty
    gixty

    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.

  18. Avatar de gixty
    gixty

    to confirm.
    After the user has edited the multi line text field, the list format is lost.

  19. Avatar de imath

    @ gixty

    what is the value of this xprofile field in MySQL ?

  20. Avatar de gixty
    gixty

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

    is that what you asked for?

    1. Avatar de imath

      not exactly, i wanted to know how mysql was storing the valie users fill in your xprofile field. this is only the name of your xprofile..

      1. Avatar de imath

        try to replace $member_data by nl2br($member_data) in $member_html…

  21. Avatar de gixty
    gixty

    Awesome!! It worked. It was so simple. Thank you so much.

    A huge sorry for going out of topic.

    Keep up the excellent work!!!

  22. Avatar de imath

    @ gixty you’re welcome 😉

  23. Avatar de gixty
    gixty

    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?

  24. Avatar de imath

    @ gixty,

    well can you paste the whole code you use, because i don’t see what you mean (sorry i’m french)….

  25. Avatar de gixty
    gixty

    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.

  26. Avatar de imath

    ok. well, what is the shortcode tag you used ?
    and did you mean this : [shortcode][bc_members][/shortcode] ?

  27. Avatar de gixty
    gixty

    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.

  28. Avatar de imath

    @ gixty,

    I must say i have no idea !! What is the return of the learn_more shortcode handle function ?

  29. Avatar de gixty
    gixty

    That’s ok, dont worry. I will see if I can solve it and post it here, thank you!

  30. Avatar de Anner
    Anner

    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

  31. Avatar de imath

    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 😉

  32. Avatar de johnnymestizo

    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

    1. Avatar de imath

      Sorry Johnny

      too much personal troubles / so few motivation to look at it.. hope you’ll find a fix.

  33. Avatar de shawn

    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

  34. Avatar de imath

    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"]

  35. Avatar de CC

    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. Avatar de imath

      je regarde dés que j’ai un moment, merci pour ton feedback

    2. Avatar de imath

      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.

  36. Avatar de CC

    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^^

  37. Avatar de imath

    Ok @ CC

    Merci pour ton feedback.

  38. Avatar de Welvin

    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. Avatar de imath

      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 😉

    2. Avatar de imath

      Ok just checked. It will be a new shortcode ! I’ll post an upgrade of the plugin this week end. Thanks @ Welvin for your contribution.

  39. Avatar de skar

    Is there a way to sort the bc_blogs items alphabetically instead of by newest, recently updated?

    1. Avatar de imath

      no as it uses BuddyPress blog loop.

  40. Avatar de Renu
    Renu

    Thanks a ton for making this Plugin. It has helped me alot 🙂 Keep up the good work.

  41. Avatar de Renu
    Renu

    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. Avatar de imath

      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.

  42. Avatar de simon

    Hi there

    How can we display activity updates per user, from all their groups?

    Regards
    Simon

    1. Avatar de imath

      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.

  43. Avatar de Joanna

    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. Avatar de imath

      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.

      1. Avatar de Joanna

        Fantastic, that did the trick – merci beaucoup. 🙂

        Thank you very much for your speedy reply.
        Joanna

  44. Avatar de Rob McClellan

    Looking for some help to increase the granularity of some of the codes, like filtering « my groups » by who is the admin instead of simply being a member.

  45. Avatar de Olaf

    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

    1. Avatar de imath

      Hi Olaf,

      thanks for your feedback. I need to upgrade the plugin in a near future, so i’ll see what i can do in this direction.

  46. Avatar de itsme
    itsme

    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!

    1. Avatar de imath

      Hi itsme,

      If you are using at least version 2.0 of Bowe Codes see https://imathi.eu/2013/05/05/bowe-codes-2-0/, then you can use the code i’ve put in this gist to force alphabetical order :
      https://gist.github.com/imath/6048371

      In a future release, i’ll add this sort order to the select box.