Skip to:

Group Blog + P2 or Posthaste

  • peterverkooijen


    I’m trying to integrate the P2 theme into the excellent Group Blog plugin, to get Twitter-like front-end posting on the Group Blog.

    Download my frankenstein monster here…

    It sorta works with javascript disabled. See /bp-groupblog/groupblog/functions.php:

    define( 'P2_JS_URL', get_bloginfo('url').'/_DISABLED_wp-content/plugins/bp-groupblog/groupblog/js' );

    When you turn on the javascript/ajax by removing _DISABLED_ , posts sent from the P2 post-form end up on the main blog, instead of the group blog. And the inline edit feature digs up all kinds of random-looking text from the database. Luckily editing them had no effect.

    Why doesn’t it work? It must be because the form is on the group homepage ( instead of a regular blog index (

    Is there a referrer check issue?

    Does P2 get the wrong blog ID?


    I’m stuck for now. It’s beyond my competence level. I may try again after my next day job deadline. Hopefully someone else is willing to pick this up.

    I also tried with Posthaste. Similar result. Will post that version for download soon.

Viewing 13 replies - 1 through 13 (of 13 total)

  • abcde666


    did you get in touch with Noel (coder of P2) yet ?



    Thanks for the suggestion + info Erich73. I sent him an email.

    EDIT: He already answered:

    Unfortunately I don’t have a good answer for you. Buddypress already works like P2 in so many ways – have you had a look at BuddyPress 1.2?

    My best suggestion is just to dig through the source, especially the javascript and php -> javascript files. They’d leave you with the best clue.

    Although, I think BuddyPress probably has all of your needs covered.

    Dead end…

    I wouldn’t call that a dead end. I’d just say that I don’t have a quick solution for you. To me, BuddyPress has everything that P2 gives you.

    If you really want P2 to work in BuddyPress, do a little investigation, try and figure out what isn’t happening. Detail your problems and how to reproduce them and get that information out there – and post a diff, instead of a zip of your theme. :)

    Mike Pratt



    I def agree with p 2 of your reply but as for p1 –

    I think there might be something you’re missing. The reason P2 has allure for BP admins is that it might easily fill a temp hole left in a very common use case of BP -> letting users post blog posts whilst avoiding the traditional back-end, non themed traditional WP post mechanism. In that regard BP does not give you what P2 does. Now, of course, there are other solutions like QuickPress and posthaste but, to my mind, P2 is a very clever way to bridge the gap until front end blogging appears in BP.

    @Peter Don’t forget the old saying about more flies with honey :-)



    @Noel and Mike Pratt, it’s relatively easy to integrate P2, Posthaste etc. into BP themes. They work fine, as long as you use them what they were developed for, on blog index/home pages.

    The problem that is the subject of this thread is that P2, Posthaste etc. break when you use them on a group home page, in combination with the group blog plugin. BTW, that’s the only place where I want front-end posting, so I’m not even that interested in how P2 is or will be integrated in BP’s default theme.

    The zip I posted is NOT my theme; it’s the bp-groupblog plugin with P2 integrated, for as far as I could figure it out. I plan to post a zip with my bp-groupblog+posthaste attempt later. I have no idea what a diff is.

    I have done more than a little investigation and reported here and at the top of this thread in some detail what isn’t happening and my attempts to figure out why.

    In the P2 case the problem must be in the javascript somewhere and may have something to do with referrer check. Anyway, when you turn on the javascript, P2 gets the wrong blog and post IDs. I have no idea why, how to fix it or even what to focus on.

    Noel’s answer was basically “Buddypress is awesome and does everything you need”. I don’t pay Noel and Noel owes me nothing, so that sounds like a dead end to me. I do appreciate he even bothered to return my email.

    I posted my zip in case anyone agrees this would be a useful feature to have and wants to take a stab at it. If not, fine also. See if I care.

    I’ll return to this probably in a week from now, after a day job deadline.

    Mike Pratt


    @Peter Apologies if I missed that subtlety earlier, but given that bp-groupbog is not even updated for 1.2 yet, are you spending all this effort integrating P2 into a 1.1.3 Groups home page?



    are you spending all this effort integrating P2 into a 1.1.3 Groups home page?

    Yes, I need it for active sites based on 1.1.3 and a heavily customized theme. I’ll probably upgrade to 1.2 during the slow Summer months, but will still keep my own theme and structure. The group blog plugin is from a user with an active site who’s probably on a similar upgrade cycle a little behind the curve. Does 1.2 have P2/front-end posting on the group home page? Will 1.3 have it?



    While it is very true that the backend is confusing our users regarding complexity, I still think that, atm, posting from the front-end is not developed far enough yet (as far as I know, please correct me if I’m wrong). It is fine for micro-blogging, but I don’t think there are option to include image/video/media uploading, tagging, and categories.

    Therefore we are still painfully educating our users so at least the can harness the full potential of WP rather than to use it as a feature rich paper weight that can only do text. If anyone knows of a way to post to the blog from the front end that’s more full featured than just text, it will be implemented immediately (as a manner of speaking)!

    We could do this with Drupal, but I have not seen it yet, or search hard enough, in WordPress.

    So yes, I to would absolutely feel liberated if I did not have to send our users to a backend…it is not what is expected for most users using common social sites. Definitely high on the priority list!



    Marius Ooms posted an update about the bp-groupblog plugin here.

    Per definition what works within your blog should also work on your groupblog. All you need is the blog id that belongs to the group. If you look at the template files you’ll see how we set the blog id and use switch blog to change blog id’s.

    That’s probably what I should focus on to fix my problem!

    Looking ahead we are even going further and reversing the concept of pulling in specific blog content into the group, but let the blog be the group and pull in buddypress information to the blog itself. … The main group slug would just forward to the blog home page.

    I had thought about that as possible solution to the referrer check mismatch problem; just make the blog homepage, where P2 does work, the group homepage.

    But I think it would create more confusion. In my theme I want to keep blogs looking like blogs and turn the group homepages into the centers for social networking activity.

    So the group blog homepage would display the same posts as on the group homepage, but in a traditional blog view. Most users would see the group blog posts on the group home page or in the single.php view.

    Forwarding the group slug to a blog and then make the blog look like a group home page breaks the logic of the site.


    I still think that, atm, posting from the front-end is not developed far enough yet … It is fine for micro-blogging, but I don’t think there are option to include image/video/media uploading, tagging, and categories

    There is in P2, leveraging WordPress media buttons. It’s very slick, with lightbox etc. (I see they’re missing from the version I had in my zip…)

    In my setup I’m trying to get simple, stripped down microblogging front-end posting on the group homepage, with a traditional blog view on the blog homepage. So more advanced users can still go from the regular blog homepage into the wp-admin backend if they want to do more complicated post editing.

    P2 has different tabs for Status Update and Blog Post on the post-form. I’d like to have those options in the group homepage if I can get it to work, but the stripped down Status Update would be priority there.

    D Cartwright


    Feel free to look at some of the code in the groupwiki plugin for frontend blog posting. Or if you’d like to chat about any of it, drop me a message :)



    Thanks for the comments and suggestions Mariusooms and D Cartwright. Lots of new leads to explore!

    I need to pull myself away from this for a few days though. Day job deadline… :-(



    Posthaste experiments go nowhere. I’m closer to a solution with P2, with the theme integrated directly into the bp-groupblog plugin (old version for 1.1.3…).

    I’ve boiled the problem down to this: I need to tell the p2.js file which blog it is operating in. Without a blogid it assumes it’s working on the main blog.

    The solution is probably in here somewhere: Get blog_id in external files. Also mentions the switch_to_blog function that Marius Ooms pointed out to me in bp-groupblog.

    How can I turn that into a line of javascript that I can add at the top of p2.js? ‘var something = something;’?

    Or should I add something to functions.php? It has functions like this:

    function latest_post_permalink() {
    global $wpdb;
    $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1";
    $last_post_id = $wpdb->get_var($sql);
    $permalink = get_permalink($last_post_id);
    return $permalink;

    What should I add to a function like this to tell it from which blog to get the last post permalink? Or can I add $blogid as global or something like that?



    Adding switch_to_blog(‘2’) to js.php produces weird, unproductive, but interesting effects. var latestPermalink correctly gets the last post of the group blog, but ajax goes haywire and makes it impossible to test if posts now end up on the right blog.

    To be continued…

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Group Blog + P2 or Posthaste’ is closed to new replies.
Skip to toolbar