Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: group member names push into array not working

@kiciana

Participant

Hi

I figured out that it’s the while loop that’s stopping the php function from responding properly

While this works just fine:

function my_action_callback() {
global $wpdb;
$names = array();
$whatever = intval( $_POST['whatever'] );
//while ( bp_group_members() ) : bp_group_the_member();
								
//$name = bp_group_member_name() ;
//array_push($names, $name);
//endwhile;
								
$rep2 = array( $_POST['whatever'] . ' successful!' );
							
echo json_encode($rep2);
die();
}

This stops the click from alerting anything

function my_action_callback() {
global $wpdb;
$names = array();
$whatever = intval( $_POST['whatever'] );
while ( bp_group_members() ) : bp_group_the_member();
$name = bp_group_member_name() ;
array_push($names, $name);
endwhile;
								
$rep2 = array( $_POST['whatever'] . ' successful!' );
							
echo json_encode($rep2);
die();
}

Any idea why is the loop wrong there?

Any help highly appreciated

Skip to toolbar