Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: BUG?: AJAX output of the Wire on profiles ignores 'post-list.php' template


4522774
Inactive

Hey Hempsworth!

I’m triyng tp build a component which make wire ajax-ified. In the sense you can post something via Ajax, without reloading the page.

I achieved to save message in background as you be able to delete it.

But I have a prob…I’m not able to able to make bp return me the “graphic” instance of the just saved wire post.

have you some ideas on how to achieve that???

This is my code used to save the wire:

function bp_wire_ajax_save_post(){ //todo: set return value

global $bp;

//print_r($bp);

if (is_user_logged_in()){

$message = $_POST['wire-post-textarea'];

if($message=='')

$message='ciaoooooo';

//save the message

$postId = bp_wire_new_post($bp->loggedin_user->id, $message, $bp->profile->slug, false, $bp->profile->table_name_wire);

$args = 'item_id=' . bp_wire_item_id() . '&can_post=' . bp_wire_can_post() ;

echo $args;

}

It work like a charm. Please don’t see some “echo” etc, they are debug info. This is not the final version :P

Now the difficult one: I use this to retrieve the graphic wire instance from template, but the loop doesn’t work…

$args ='item_id=' . $_POST['bp_wire_item_id'] . '&can_post=1';

$args = 'item_id='.$bp->loggedin_user->id.'&component_slug='.$bp->current_component.'&max=1&per_page=1&can_post=' . bp_profile_wire_can_post() ;

$args = 'item_id=' . bp_wire_item_id() . '&can_post=' . bp_wire_can_post() ;

echo $args;

<?php if ( bp_has_wire_posts( $args ) ) : ?>

//print wire

but it show me always “no wire to post”

someone could help me???

Skip to toolbar