You can can read the cookie and check if the current user is logged in using get_current_user_id(). If they are just save the cookie value to the user_meta.
$cookie_name="";
if( isset( $_COOKIE[$cookie_name] ) ) {
$user_id = get_current_user_id();
if( $user_id ) {
$meta_key = $cookie_name;
$meta_value = $_COOKIE[$cookie_name];
update_user_meta( $user_id, $meta_key, $meta_value );
}
}
Related Posts:
- Shared functionality in plugins and themes
- Keep one user logged for a year?
- Plugin (or Theme) containing its own Plugins?
- How to enable edit button in the theme’s customize UI?
- Themes VS Plugins [duplicate]
- Recommendations for books/resource to get started with wordpress 3 development (plugins/themes) [closed]
- ‘Customize’ button in admin bar for CSS
- Auto delete WordPress users according to time
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- How to get current post user id
- How to read individual user’s directory and display content to that specific user?
- Custom wordpress Theme and Plugin repository
- “No Add Button” for me to customize my WordPress with themes and pluggins
- Basic gallery plugin suggestion [closed]
- how can I query all wordpress users of a blog
- Moving FB comments at the end of page
- How to handle a WordPress blog with articles in different languages?
- display unique post per category
- Display WordPress comments before the plugins?
- Mobilepress fails to translate short codes
- How to prevent plugin, theme installation failures on WordPress?
- Can we hide a certain user in WP?
- How Can I Increase Breadcrumb Position Count (Starting From 2)?
- How can I store user preferences in WordPress and retreive them later?
- WordPress delete cookie
- Confusing problem with displaying message recipient metadata
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Need Help Creating a Multi-Step, Video-Guided Enrollment Site
- Issues with Post 2 Post Plugin
- How can I modify the colors of my theme for a single section of my site? [closed]
- do_shortcodes() isn’t working
- How to make wordpress backend mobile optimized.?
- How to give different user access to different people?
- Looking for a Table of Contents (TOC) plugin for WordPress
- WordPress Plugin Development In MVC Architecture, How?
- GPL and plugins
- Disable Specific Widgets on Selected Pages of a WordPress Website?
- Create page when plugin is activated
- How to show custom message once on plugin activation?
- Post source link plugin – small modification
- How to add users roles dropdown in registration in wordpress
- How to load a new template page according to a particular URL?
- Can a plugin add to header/footer/body content?
- Removing WordPress Plugin Menu Item for a specific user
- Set cookie then immediantly refresh the page
- Override the core function locate_template
- Organising the plugins folder in wordpress
- Installing WordPress only for a separate page – ‘mydomain.com/blog’
- Reset WordPress website
- Output HTML only on individual post view
- Uncode theme content block header ignoring saved changes/not updating?
- How to create user groups and allow custom posts and plugin modify/access to specific group?
- How would I go about creating a user ranked post popularity page?
- User Session and Stored Cookies not get removed
- posts comments goes to trash
- What will happen if i deactivate my visual composer plug in? [closed]
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- Translation plugin to translate another plugins
- How can I list all installed plugins/themes/versions from CLI/API?
- How to create multiple users at once?
- Shortcode to update user meta
- How to protect WordPress from security scanner [closed]
- Contact Form 7 – Form name blank [closed]
- Text change in Advanced Customs Fields [closed]
- Loop in elementor custom widget not working
- get_users(); Is an Undefined Function When Used in Cron Job
- How to include files relative to a file’s directory
- .php file for woocommerce edit category? [closed]
- How to display an alert when deleting a plugin?
- Cookies set by a plugin in wordpress for tracking
- Auto populate a user custom field from another user custom field
- Getting infinite scrolling working on my custom template
- How to override any plugin file in the child theme
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Mobile Menu and Mobile Sidebar missing
- Adding discount functionality to the cart
- Changing the CSS with a plugin
- Precheck fields when I add a new post
- How To Export User’s Custom Fields in CSV or XLSX
- Paid Membership Pro displaying a user name in PHP
- Searchable Semi Random Number Generator on User Profiles
- Is it possible to disable a theme programmatically?
- Google trying to index child theme files
- Automatically check “Enable stock management at product level” to the existing products?
- Creating Nested custom fields
- In the WordPress API is there a way to set the width of the post/page container
- How to restrict “too soon” downloads with a general rule?
- Display Powerpress media url
- Child Theme Changes Are Not Reflecting In Parent Theme
- Input gets deleted/overwritten after changing to different Admin Menu
- Breadcrumb is not generating the correct post page url
- Display static pages instead of category, in code
- User register hook can’t access form request
- ERROR: Cookies are blocked due to unexpected output – no access to FTP
- Install theme as part of a plugin
- Divi Template A Few Questions
- Trying to use wp_register_script/style and enqueu them from an array – getting an error [duplicate]
- Real estate schema markup not showing up on Rich Results test
- Convert from Portfolio post to WooCommerce products [closed]
- Local WP site can’t locate plugins or theme