It depends how you want to uniquely identify users. Some options to uniquely identify people might be the:
- The WordPress User ID. If people are logged in then using their WP User ID is a good option.
- The WordPress session ID. This is unique to the session; People will get a new session after some amount of time, and if they change browser or clear their cache, etc.
- The Browser User Agent. This is another option that will change less frequently but still might change, but will solve your problem quickly
Whatever you choose, you can simply change both of these lines in your code to user more specific method. E.g. I would suggest trying IP + User Agent:
$user_IP = $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'];
This will mean each like is then unique to IP plus browser user agent string, which should solve the problem you stated.
Related Posts:
- Where the Nickname is being used in WordPress
- Confusing problem with displaying message recipient metadata
- Building a scalable WordPress favouriting plugin – one serialised meta value array or many meta records
- delete_user_meta Delete one value out of array
- Upload files programmatically to users
- Current user in plugin returns NULL
- update_user_meta add value on the top on existing value
- Set user ID at time of wp_create_user
- Average Account Age
- How to get current post user id
- New User Form – Custom Menu Page
- Modifying Author Link to add Author Meta in URL
- How can I change the meta_key for a particular piece of information?
- Shortcode to update user meta
- How to get all posts belongs to a user between a certain date
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Search users with custom meta data
- WordPress /users/me endpoint request forbidden
- Disable Author Archive just for certain roles in bulk
- Auto populate a user custom field from another user custom field
- Access remote SFTP server via WordPress login?
- User updating their profile wipes my custom fields
- How To Export User’s Custom Fields in CSV or XLSX
- Get all user meta_keys and then group users by matching values
- WordPress plugin from own server
- How to avoid plugin name conflicts from the upgrade notifier?
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Add content to /wp-admin/plugin-install.php admin screens
- How do I only load a plugin js on it’s settings pages?
- Need a function for changing saved post_date or post_date_gmt to relative time in wordpress
- Activate Plugin which is in subfolder?
- Removing user contact methods works from functions.php but not from a plugin
- Autoload via composer in plugin interference
- Can WordPress plugins “Talk to each other”?
- How do I store information in a dynamic block in WordPress?
- Is it possible to set up multistore in Woocommerce? [closed]
- Plugin exceeds memory limit
- Find the URL of the current plugin directory
- Plugin Paths Issue
- How to generate video out of images via WordPress plugin
- Help With MySQL to WPDB Query Conversion
- code is working properly in Core PHP but writing coding in WordPress
- Custom plugin init action causing general slowness
- Enable users to change change and add taxonomies of posts
- How to get the permanent link in a plugin?
- Duplicate results are displayed in a custom plugin [closed]
- Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?
- custom uploader in the admin area
- Best/Correct way to add an option to a category
- Basic question about accessing scripts in my plugin
- I receive taxonomy id
- Loop in elementor custom widget not working
- get_users(); Is an Undefined Function When Used in Cron Job
- WordPress SVN UTF-8 issue
- Asynchronous request in wordpress
- How to access OOP plugin function inside themes or other plugin
- change or add css to theme from plugin
- Displaying data from another database
- Every time I de-activate a custom plugin, the site encounters a critical error
- Custom Fields for Page Edits
- How do I remove all traces of a plugin?
- Is it possible/advisable to set last stable version to previous version?
- How to make sure settings are not lost when plugin is updated?
- How to override any plugin file in the child theme
- How can replace this url
- How to overwrite a plugin?
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- SimpleXML is not working with xml response from external api
- Custom Plugin Update
- How do I stop plugins and themes from getting updated in a new plugin?
- Custom wp_list_tables redirect on specfic page
- On button click, redirect users to registration page instead of another page
- Hook to display element as product on category page
- Searchable Semi Random Number Generator on User Profiles
- Missing files in enqueue actions causes WordPress to reload
- I can’t use WP_Query
- Adding/ Removing actions for plugins
- plugin not hooking to my custom hook
- WP Plugin: Print javascript in header
- Adding list of Indexes in wordpress document
- API Functions to Register and Show WordPress List Tables
- How to save default values into an option and delete those upon actvation and deactivation in wordpress?
- How to Add Jquery FullCalendar in wp plugin in admin
- Ajax, jQuery and WordPress
- Add custom fields in the new and edit the site forms without touching the WP core
- Extend WordPress REST API with Scheme Pro Plugin
- How to submit the custom form data in database in WordPress without plugin?
- Unable to show 4 products in a row
- WordPress check box unchecked on null value ternary operator [plugin development]
- Embed php code in custom field of a plugin [closed]
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- manage_{taxonomy}_custom_column not working
- Suitable hook when creating, updating and deleting posts programmatically
- How to be Variables and options must be escaped when echo’d?
- How to override plugin function in code snippets WordPress
- How can I gather forums posted by visitors from different sites in one place? [duplicate]
- How to make content as required in custom post type?
- How to create a “Most Popular” & “Latest” TAB in WordPress