I am really struggling on this one. This file works fine on my local dev site with no warnings. Putting it on a live site causes a fatal error, stopping the activation. I am finding it impossible to find the unexpected ending reason here. I have tried with two different live sites as well...
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
function the_note_form( $atts ){
// prepare $home_page for defualt return to the homepage after note submit
$home_page = get_home_url();
//get current users id
$users_id = get_current_user_id();
// shortcode information
$id_location_form = shortcode_atts( array( 'location' => '', 'title' =>'', 'redirect' => $home_page, 'category_custom' => '', 'create_logged_out' =>'', 'create_logged_in'=>'', 'create_by_user_id' =>'', 'show_setup' =>'', 'id_can_see' => '0' ), $atts );
//get a time stamp for the note
$entry_date = date('l jS \of F Y h:i:s A T'); //echo"$entry_date";
// get current users name
$user_info = wp_get_current_user(); $users_name = $user_info->display_name ;
if ($id_location_form['create_logged_in'] == 'yes' && is_user_logged_in() == "true") {include('form_build.php');}
//logged out form
if ($id_location_form['create_logged_out'] == 'yes' && is_user_logged_in() != "true") {include('form_build.php'); }
//specify only a user id tha can access the form.
if ($id_location_form['create_by_user_id'] == $users_id && $id_location_form['create_by_user_id'] != '') {include('form_build.php'); }
//if the show_setup = yes then show this var_dump of the setu array
if ($id_location_form['show_setup'] == "yes"){ ?> <pre> <?php print_r($id_location_form); ?> </pre>
<?
}
//close the function
}
add_shortcode( 'the_note_input_form', 'the_note_form' );
/****************************
form input to database
*******************************/
$security_input = 0;
if ( isset( $_POST["submit_form"] ) && $_POST["visitor_note"] != "" ) {
$table = $wpdb->prefix."my_notes";
$name = strip_tags($_POST["visitor_name"], "");
$note = strip_tags($_POST["visitor_note"], "");
$vis_id = strip_tags($_POST["visitor_id"], "");
$input_location = strip_tags($_POST["input_location"], "");
$date_stamp = strip_tags($_POST["utc_create"], "");
$category_custom = strip_tags($_POST["category_custom"], "");
$id_can_view = strip_tags($_POST["id_can_see"], "");
$status = strip_tags($_POST["status"], "");
$wpdb->insert(
$table,
array(
'name' => $name,
'note' => $note,
'user_id' => $vis_id,
'time_of_entry' => $date_stamp,
'input_location' => $input_location,
'category' => $category_custom,
'id_can_view' => $id_can_view,
'status' => $status,
'security' => $security_input
)
);
}
This was marked as a duplicate by another user, yet, the issue was resolved around the difference between server setups, not strict syntax in itself as both were right, yet not obvious to the different setup. Not sure why the user marked this as a duplicate really...it also quizzed another user who missed the issue as well, so an interesting consideration to discuss as far as I can see.