Hi When I click on my approve button it sends a confirmation letter to the user and adds the members information to the main members table from the members temp table.
Every thing works fine but the email is causing about a 10 second delay for my ajax. Once the accout approve it refreshes the div but takes 10 second to refresh because of email library.
How to make that it faster.
Every thing works fine but the email is causing about a 10 second delay for my ajax. Once the accout approve it refreshes the div but takes 10 second to refresh because of email library.
How to make that it faster.
Code:
<script type="text/javascript">
$(document).ready(function() {
$(document).on('click', '#button-approve', function() {
$.ajax({
url : "<?php echo base_url(); ?>admin/members/dashboard/approve_member_login",
type : "POST",
dataType : "json",
data : {
"approve_member" : true,
"member_temp_id" : $(this).attr('data-id')
},
success : function(data) {
if (data['success'] = true)
{
$('#new_member_approve').load(document.URL + ' #new_member_approve');
}
},
});
});
});
</script>PHP Code:
public function approve_member_login() {
$json = array();
if ($this->input->post('approve_member')) {
$newmembers_info = $this->get_temp_members($this->input->post('member_temp_id'));
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'email',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('myemail', 'Admin');
$this->email->to($newmembers_info['email']);
$this->email->subject('Account Approved');
$this->email->message('Hi, Just to confirm that your account has now been approved at Admin Area');
$this->email->send();
$insert_data = array(
'username' => $newmembers_info['username'],
'email' => $newmembers_info['email'],
'password' => $newmembers_info['password'],
'firstname' => $newmembers_info['firstname'],
'lastname' => $newmembers_info['lastname'],
'status' => '1'
);
$this->db->set($insert_data);
$this->db->insert('members');
$this->db->where('member_id', $this->input->post('member_temp_id'));
$this->db->delete('members_temp');
$json['success'] = true;
}
$this->output->set_content_type('application/json');
$this->output->set_output(json_encode($json));
}