Assistance With Broken Code
-
I’m currently trying to have my private training site email the admins when a page is visited by a logged in user… I have it set up so that it deposits a cookie upon the first visit, then upon consequential visits it send a different message with the “last visit” timestamp. I am using a plugin to ensure this is placed into the functions.php correctly, so it must be the code that isn’t working. We have all of our employees accept cookies, so I have already ruled that out as an issue! Any help is greatly appreciated!
(any references to (email visible only to moderators and staff) are normal email address… I just changed them here to keep them private)
function application_notification() { $visit_time = date('F j, Y g:i a'); $postid = get_the_ID(); if(!isset($_COOKIE['first_app_notification_visit_time']) && !$postid = 1388) { $last_app_page_visit = $_COOKIE['first_app_notification_visit_time']; $user = wp_get_current_user(); $user_email = $user->user_email; $to ="(email visible only to moderators and staff)"; $subject = "First App Page Viewed Again"; $msg = 'User and User, <br> <br>'; $msg .= "$user_email"; $msg .= "just opened the page to begin their first application for the again. The last time they viewed it was on <br> "; $msg .= "$last_app_page_visit"; $headers = 'MIME-Version: 1.0' . "rn"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn"; $headers .= 'From: Training Site <(email visible only to moderators and staff)>' . "rn"; $headers .= 'CC: (email visible only to moderators and staff)' . "rn"; wp_mail($to, $subject, $msg, $headers); unset($_COOKIE['first_app_notification_visit_time']); setcookie('first_app_notification_visit_time', $visit_time, time()+31556926); } else ($postid = 1388) { $to ="(email visible only to moderators and staff)"; $subject = "First App Page Viewed"; $msg = 'User and User, <br> <br>'; $msg .= "$user_email"; $msg .= "just opened the page on the training site to begin their first application for the first time!" ; $headers = 'MIME-Version: 1.0' . "rn"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn"; $headers .= 'From: Training Site <(email visible only to moderators and staff)>' . "rn"; $headers .= 'CC: (email visible only to moderators and staff)' . "rn"; wp_mail($to, $subject, $msg, $headers); setcookie('first_app_notification_visit_time', true, time()+31556926); } } } } add_action('init', 'application_notification'); -
Coding is beyond the scope of this forum. You could try to get help on the wordpress.org forums or in a forum dfedicated to coding.
-
- The topic ‘Assistance With Broken Code’ is closed to new replies.