Custom Plugin Nightmare!!

Im customising a custom plugin and finding it very confusing.
He seems to have made a very chaotically coded plugin where I cant find many of the codes for the output,

http://brismax.surgery/referral-form/
This is the form thats made from a custom plugin.

THIS IS HOW THE DATA IS EMAILLED TO DR:

PATIENT DETAILS
Patient Title Ms
Patient Name test
Address testadress
Contact Number (011) 111-1111
Email Address [email protected]
Provider No 111Provider NO
Date of Birth 2017/02/21
Additional Information Work Cover
Reason for referral

Tooth Number 1 = 8

Tooth Number 2 = 8

Tooth Number 3 = 1

Tooth Number 4 = 1

enter the details for each tooth or type your own referral reason testCOMMENT
Post Space Yes
X-ray Attachment

DENTIST / PRACTITIONER DETAILS
Name chris cullen
Email Address [email protected]
Practice Name PracticeName
How would you like your report sent back to you? Via Email

Below is the code of the PLugin:
[php] <?php

global $wpdb;

$query = "SELECT * FROM wp_posts WHERE post_type='patient_referral' ORDER BY id DESC";


if(count($wpdb->get_results($query))>0){
	$result_form = $wpdb->get_results($query,ARRAY_A);
}	

?>

Referral Form

<div class="container admin_container">
    <div class="row">
		<div class="col-md-12">
		<?php if($result_form){?>
		<table id="ST_TABLE" class="table table-striped" >
            <tr>                  
                <td>#</td>                        
                <td width="100">Patient Title </td>
                <td>Patient Name </td>
                <td>Contact Number </td> 
                <td>Email Address </td>                        
                <td width="100">Date of Birth </td>
                <td>Dentist Name</td>
                <td>Dentist Email Address </td>                        
                <td width="100">Delete</td>                                    
            </tr>
			<?php
				$count	=	0;  
                foreach($result_form as $data){
                         							                                                   
						echo "<tr>";
						echo "<td>".(++$count)."</td>";
						echo "<td><a href='/wp-admin/admin.php?page=singl_referral_form&id=".$data['ID']."'>".ucfirst($data['post_title'])."</a></td>";
						echo "<td>".ucfirst(get_post_meta($data['ID'],'patient_name',true))."</td>"; 								
						echo "<td>".ucfirst(get_post_meta($data['ID'],'patient_phone',true))."</td>";
						echo "<td>".ucfirst(get_post_meta($data['ID'],'patient_email',true))."</td>"; 												
						echo "<td>".ucfirst(get_post_meta($data['ID'],'patient_dob',true))."</td>";
						echo "<td>".ucfirst(get_post_meta($data['ID'],'dentist_name',true))."</td>"; 
						echo "<td>".ucfirst(get_post_meta($data['ID'],'dentist_email',true))."</td>"; 
						echo "<td class='acc_action'><a onclick='delete_details(".$data['ID'].")'>Delete</a></td>"; 		
						echo "</tr>";
                  }

                ?>
                
             </table>
             <?php }else{ echo '<h3 class="acupt_error">No Records Found</h3>';}?>
		</div>
      

		<div class="loader "></div>
	</div>
</div>
.loadinggif { background:url('images/loadinggifconfig.gif') no-repeat right center; display: inline-block; height: 100vh; vertical-align: middle; width: 100%; position: absolute; top: 0px; /* left: 0%; */ background-color: rgba(0,0,0,0.4); } .acupt_error{ color:red; font-size:12px; } .wrap.gallery-wrap { background: #fff; padding: 20px; overflow: hidden; } .acc_action{ cursor:pointer; text-decoration:none; color:blue; } #wpwrap{ background:#F1F1F1; } .admin_container{ padding:10px; margin-top:20px; } .table { width: 94%; } [/php]

AND:

[php] <?php

global $wpdb;

$query = "SELECT * FROM wp_posts WHERE post_type='patient_referral' AND ID=".$_GET['id']." ORDER BY id DESC";
if(count($wpdb->get_results($query))>0){
	$result_form = $wpdb->get_results($query,ARRAY_A);
}	

?>

Referral Form Details

<div class="container admin_container">
    <div class="row">
		<div class="col-md-12">
		<?php 
			if($result_form){
               foreach($result_form as $data){
                   
				$image	=	explode(",",get_post_meta($data['ID'],'xray_attachment',true));
				foreach($image as $value){
					$file_details	.=	"<p><img src=".$value." height=250 width=300 /></p>";
				}
				         							                                                   
				echo '
				<table id="ST_TABLE" class="table table-striped" >
				<tr><th colspan="2">Patient Details</th></tr>
		 		<tr>
		 			<td style="">Patient Title</td>
		 			<td>'.ucfirst($data['post_title']).'</td>
		 		</tr>
				<tr>
					<td>Patient Name</td>
					<td>'.ucfirst(get_post_meta($data['ID'],'patient_name',true)).'</td>
				</tr>
				<tr>
					<td>Address</td>
					<td>'.ucfirst(get_post_meta($data['ID'],'patient_address',true)).'</td>
				</tr>
				<tr>
					<td>Contact Number</td>
					<td>'.ucfirst(get_post_meta($data['ID'],'patient_phone',true)).'</td>
				</tr>
				<tr>
				<td>Email Address</td>
				<td>'.ucfirst(get_post_meta($data['ID'],'patient_email',true)).'</td>
				</tr>
				<tr>
				<td >Date of Birth</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'patient_dob',true)).'</td>
				</tr>
				<tr>
				<td > Additional Information </td>
				<td >'.ucfirst(get_post_meta($data['ID'],'additional_info',true)).'</td>
				</tr>
				<tr>
				<td>Reason for referral</td>
				<td > 
				
				
				<p>Tooth Number 1 = '.ucfirst(get_post_meta($data['ID'],'teeth1',true)).'</p>
				<p>Tooth Number 2 = '.ucfirst(get_post_meta($data['ID'],'teeth2',true)).'</p>
				<p>Tooth Number 3 = '.ucfirst(get_post_meta($data['ID'],'teeth3',true)).'</p>
				<p>Tooth Number 4 = '.ucfirst(get_post_meta($data['ID'],'teeth4',true)).'</p>
				</td>
				</tr>
				<tr>
				<td >Enter the details for each tooth or type your own referral reason</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'comments',true)).'</td>
				</tr>
			//	<tr>
				//<td > Post Space</td>
			//	<td >'.ucfirst(get_post_meta($data['ID'],'post_space',true)).'</td>
				//</tr> 
				<tr>
				<td >Would you like us to contact you to further discuss this referral?</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'contact_like',true)).'</td>
				</tr>
				<tr>
				<td > X-ray Attachment</td>
				<td >'.$file_details.'</td>
				</tr>
				</table>
				
				
				<table class="table table-striped" >
				<tr><th colspan="2">Dentist / Practitioner Details</th></tr>
				<tr>
				<td >Name</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'dentist_name',true)).'</td>
				</tr>
				
				<tr>
				<td >Email Address</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'dentist_email',true)).'</td>
				</tr>
				<tr>
				<td >Practice Name</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'dentist_practice',true)).'</td>
				
				</tr>
				<tr>
				<td >Would you like a copy of this referral emailed to you?</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'copy_email',true)).'</td>
				</tr>
				<tr>
				<td >Would you like a copy of this referral emailed to your patient?</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'patient_referal',true)).'</td>
				
				</tr>
				<tr>
				<td >Have you referred to our practice before?</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'practice',true)).'</td>
				</tr>
				<tr>
				<td >Has the appointment been arranged?</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'appoinment_arrange',true)).'</td>
				</tr>
				<tr>
				<td >Preferred Location</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'prefer_location',true)).'</td>
				</tr>
				<tr>
				<td >How would you like your report sent back to you?</td>
				<td >'.ucfirst(get_post_meta($data['ID'],'report_sent',true)).'</td>
				</tr>
				</table>
				';
                }
			}
			else{ echo '<h3 class="acupt_error">No Records Found</h3>';}
			?>
		</div>
      

		<div class="loader "></div>
	</div>
</div>
.loadinggif { background:url('images/loadinggifconfig.gif') no-repeat right center; display: inline-block; height: 100vh; vertical-align: middle; width: 100%; position: absolute; top: 0px; /* left: 0%; */ background-color: rgba(0,0,0,0.4); } .acupt_error{ color:red; font-size:12px; } .wrap.gallery-wrap { background: #fff; padding: 20px; overflow: hidden; } .acc_action{ cursor:pointer; text-decoration:none; color:blue; } #wpwrap{ background:#F1F1F1; } .admin_container{ padding:10px; margin-top:20px; } .table { width: 94%; } [/php]

THE PROBLEM:

  1. The teeth section is required but it shouldnt be.
  2. The provider details are listed on the email under patient details. I cant find the code that says where to display this data.
  3. The Telephone number format is incorrect.

I cant really find all these elements in the code.

This doesn’t look to be particularly well written.

I would use a form plugin and a custom post type to do this.

Try Caldera Forms, WeForms or Gravity Forms for this it will save you a lot of headaches.

HEY Valkinder,
It seemed like a very disorganised plugin to me - but im no expert.

I have since used my own code and left it out.

BTW is there any PHP forum that gets faster answers, Im trying to learn but there doesnt seem to be as much php support as html js etc.

Thanks man

Just depends on the question. I am generally watching this site monday - friday, but I don’t touch WordPress development, if I can get away with it.

Sponsor our Newsletter | Privacy Policy | Terms of Service