kldesigns
11/14/2017 - 12:14 PM

BB Hook

how to run php using bb hook


add_action('fl_content_open', 'networklist');
function networklist(){
	$networklist = array();
$current_user = wp_get_current_user(); 

$user = pods('user', $current_user->ID);
$business = $user->field('user_business');

$params = array( 
     
    // Be sure to sanitize ANY strings going here 
    'where'=>"business_owner.id = $business" 
); 

$ingredientspod = pods( 'ingredient', $params );
$ingredientcounter = $ingredientspod->total_found();
if ($ingredientcounter > 0 ) {
while ( $ingredientspod->fetch() ) {
array_push($networklist,$ingredientspod->field( 'supplier' ));
}
} else {
array_push($networklist,"none");
}

$salepod = pods( 'sales', $params ); 
$salecounter = $salepod->total_found();
if ($salecounter > 0 ) {
while ( $salepod->fetch() ) {
array_push($networklist,$salepod->field( 'buyer' ));
}
}

//$networklistu = array_unique($networklist);
$networklistu = $networklist;
$arrlength = count($networklistu);

if (empty($networklist)) {
$mytext = "<div><h2>There are no businesses in your network yet</h2></div>";
} else {
$mytext = "<div><ul>";
for($x = 0; $x < $arrlength; $x++) {
$mytext .= "<li>";
$arr = $networklistu[$x];
$mytext .= $arr['post_title'];
$mytext .= "</li>";
}
$mytext .= "</ul></div>";
}

	$hi = "<script>function changeContent () {var myelement = document.getElementById('network');
    myelement.innerHTML= '".$mytext."';}
    window.onload = changeContent ;</script>";
	echo $hi;
	
}