You’ve got one very large issue here – you’re using $_SESSION
.
WordPress, by default, doesn’t use session variables. So isset( $_SESSION['vsp_user'] )
will always return false
because WP isn’t keeping track of things.
There are some additional changes you’ll need to make and hooks you’ll need to tie in to in order to enable sessions in WP. Just to get you started, here are some resources:
- Adding Sessions in WordPress
- Using Sessions in WordPress
- Using sessions in WordPress (Yes, this is a different article)
- How To: Enable the Use of Sessions in Your WordPress Blog
Once you’ve actually got sessions turned on, you should see far less “false positives” in your stat tracking.
Related Posts:
- Fail to get the total number of posts
- Child theme – Overriding ‘require_once’ in functions.php
- Sort posts by Date (DESC) and by Title (ASC)
- Remove a menu item created by a plugin
- Using wp_get_nav_menu_items() to list children of children pages
- Custom menus displaying all pages instead of set pages
- Show Video in Excerpt
- How Can I Access a PHP Variable in Another PHP Function
- How to fix a theme with page.php Default Template that accidentally deleted?
- Override parent theme function that is not hooked or in the functions.php file
- Theme Demo in live Site
- function to include is_home, is_archive, is_category, is_author etc in one function?
- Change a sidebar name?
- Removing title from page
- get_the_excerpt() not returning anything when post has no excerpt
- Why isn’t is_page_template() adding a body class?
- Query children and parent title
- Creating loop within functions.php
- Limit filter upgrader_post_install to a single plugin
- How to use max and min values of custom fields
- creating shortcode to pull json array
- Still relevant method of embedding images in WP Theme in 2018
- Pass Shortcode Attribute to footer Script
- How to use Internationalized human_time_diff() function in Chinese?
- post to subcategory and parent in wp_insert_post
- Variable if post is sticky in functions.php
- Execute a ultimate member action when user role is updated
- Create a new query in function.php to filter blog posts
- Use third party Library in wordpress
- Creating new blog on multisite programatically without hacks?
- Allowing users to view private posts (pending approval)
- How to get correct URLs in network wide menu (Multisite)?
- Remove category from url
- Optimizing a WordPress site
- different style sheet for just one page template
- How to add custom JavaScript in functions?
- How to target post and pages and not all post types in admin?
- srcset and custom field get_post_meta and wp_get_attachment_url
- hide shortcode using hooks
- Adding code using functions.php in child theme
- Passing global variable from header.php to functions.php
- Extending a custom framework built into WordPress to automatically turn the ‘Search Engine Visibility’ setting ON / OFF, dependant on environment
- Page get parameter doesn’t work with is_single() function
- How is $current_page passed in woocommerce_account_orders function?
- Filter to wp_list_authors
- Contact Form 7 If Condition
- display a div on ervery site but not frontpage?
- How can I change the size of the text in Word Press
- Using depth=n in wp_list_pages
- shorthand syntax for custom fields
- How do I pull avatar from post using BuddyPress? [closed]
- Replace header image on all other pages but home – URL issue
- Show admin page, only if function is being used
- Get users with different roles and call function on each of them (user_meta)
- Getting images from media library and get_the_date() not working
- Show errormessages on wrong username/password on custom loginform?
- Using add_image_size in functions.php to get original uploaded file
- Show metadata in users.php – wordpress
- Add version # to wp_register_style function
- How to remove font awesome from loading in wp theme
- Gravity Forms – Custom Merge Tag Convert date_created to Local/WordPress Time?
- Add custom css file after plugin css with WordPress Child Theme functions.php
- Remove check boxes and its label from screen option for custom role
- Removing comment lines from all enqueued js files using a filter function
- Fatal error: Call to undefined function load_theme_textdomain() in /var/www/vhosts/61/151172/webspace/httpdocs/wp-includes/functions.php on line 5
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- Button click counter for login user
- Auto copy value from specific user meta field to another field
- Variable function names
- Route wordpress with template
- Change is_front_page() to is_page() to display ‘hero’ on entire site?
- Some code is added automatically to my site’s header – what is it?
- Function causes edit_post_link to link to the wrong post
- To make some div display for a longer time
- Getting back a blank WordPress site following functions code edit
- Insert menu into theme location depending on user logged in/out status
- Add functionality to post editor
- Define an extra field for all pages (with no plugin?)
- Set thumbnail from URL, by grabbing image in functions.php
- admin-ajax.php nulls all php variables
- How to remove “login to reply” from individual comments [duplicate]
- Why functions metaboxes is causing White Screen in Admin [closed]
- Rename file after title , one small problem
- Adding function to function.php error 505 [closed]
- image_size with respect to aspect ratios
- Is mytheme_post_thumbnails() still necessary?
- Get full slug for a WordPress Post
- My website is generating weired url parameters of paginated pages
- Whats the proper way to add a new user via a front end form?
- When the WP_EDITOR button is pressed, the user is prompted to select a photo from their device
- How to crop image in WordPress with aspect ratio for any size of image
- Bad value crossorigin for attribute crossorigin on element link
- Logout redirect via page template without confirmation?
- How can I modify or filter this variable in an existing class? (Mai Theme)
- Get category of post inside save_post hook
- Custom customizer CSS priority
- Custom HTML structure in customizer not rendring in Browser
- iOS and ajaxComplete
- Log in and out using custom pages, no logout confirmation and redirects for logging in and out 2023
- Copy and Modified WooCommerce function is_coupon_valid [closed]