in there i have profile_driver
, i want to make this data will show when i input the parameter first. example input the 'id'
$command = $_GET['command'];
switch ($command) {
case 'profile_driver':
if(!empty($_REQUEST['id'])) {
$data = array( "api_status" => 0, "api_message" => "cant Find data");
echo json_encode($data);
} else {
$loop = new WP_Query(
array(
'post_type' => 'drivers'
)
);
if( $loop->have_posts() ) :
$data = array( "api_status" => 1, "api_message" => "success");
$meta = array();
while ( $loop->have_posts() ) : $loop->the_post();
$meta[] = array(
"id" => get_the_ID(),
"post_name" => get_the_title(),
"username" => get_post_meta( get_the_ID(), 'username', true ),
"password" => get_post_meta( get_the_ID(), 'password', true ),
"email" => get_post_meta( get_the_ID(), 'email', true ),
"phone" => get_post_meta( get_the_ID(), 'phone', true ),
);
endwhile;
endif;
echo json_encode($meta);
}
break;
}
here when i try to run in postman( i have the data with the right id ) :
have someone help me improve my code so my code can be work like what i want ?