// ADMIN
$user_id = 1;
require_once (ABSPATH . ‘wp-includes/pluggable.php’);
if (!is_admin())
{
// DEMO USER
$user_id = 6;
}
if ($current_user_id != $user_id)
{
$user = get_user_by(‘id’, $user_id);
if ($user)
{
wp_set_current_user($user_id, $user->user_login);
// wp_set_auth_cookie($user_id);
if (wp_validate_auth_cookie('', 'logged_in') != $user_id)
{
wp_set_auth_cookie($user_id);
}
// do_action('wp_login', $user->user_login);
}
}
Related Posts:
- WordPress and PHP Sessions – Security and Performance
- How should you hook a session_start() when authoring a plugin?
- Does using set_transient() function can lead to MySQL problems?
- Sessions not creating correctly in custom function
- Why is my javascript not invoked in my hooks except wp_head?
- External Authentication, session_tokens not destroyed on logout
- Custom login doesn’t work properly
- captcha not working in my custom plugin
- Displaying “One Time” Notification in Plugins
- Can we intercept user_login and user_pass from a wp_login_form?
- Updating transient value frequently
- How do I validate extra pin field on my WordPress login form page?
- Hiding the WordPress login and password fields from login page
- how to add security questions on wp-registration page and validate it
- $_SESSION inside php function executed by AJAX
- Sessions in plugin development?
- Create a Custom Login System in WordPress [closed]
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How can I add an image upload field directly to a custom write panel?
- Creating a table in the admin-style?
- What process do you use for WordPress development? [closed]
- On the WordPress Admin section how do I link to submenu pages created for a plugin?
- How to return only certain fields using get_posts()
- Where to put third party PHP library?
- Add a new tab to WordPress Plugin install Listing
- Scheduled events disappear from events queue
- How to integrate a PHP webmail script into the backend of WordPress?
- How to log plugin errors to plugin error_log file
- Custom Post Type Link from Plugin
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Using wp_cron with custom time interval and the register activation hook
- Conditional check to see if a bootstrap.css is included in a theme
- Throw 403 in a plugin [duplicate]
- WordPress multisite apply different options over each site from same plugin
- Using ob_start() in plugin
- Create Element From Dynamic HTML String [closed]
- How can I view all WP generated thumbnails in Media Manager?
- Only allow plugin to be activated on root site of multisite
- what is the best practice for including ‘wp-includes’ classes
- Custom Plugin Database relations
- Save user-specific options in WordPress admin
- How to put placeholder text in the main post input area?
- How can i get the title i specified in add_options_page for my header
- use __($str) to translate strings (symfony/twig)
- Is there a way to list tags order by post_meta field
- how to redirect to another post without getting headers already sent error?
- Redirect user to a particular link in 10 seconds after using wp_die
- Change template dynamically
- add a class when login
- Proper way to run wp_query from inside a plugin
- Programmatically detect if wp-cron is disabled?
- Buddypress function and global $bp question
- Widget is to be compatible with all themes
- How to create a table with filters for my plugin
- Maximum lifetime for nonce
- wp_insert_user() function password never match
- How to setAttributes in Gutenberg block?
- Adding rewrite rule dynamically
- Prevent third party plugin’s admin page access based on user type
- I have 2 plugins using the same wp_login action hook and one is not working
- Using a multiple element in widget form
- How can I avoid conflicts between plugin and theme?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- Update Data parameter of a wp_localize_script() call
- $wpdb->prepare with LIKE and sprintf
- Quasi-custom API Call Plugin
- Show content without a post
- WP ajax requests not stacking?
- Full documentation about $args for register_rest_route?
- Is it possible to load the css just on my plugin admin page?
- WP Plugin with Upgrade option
- How can I control if post updated
- How to create taxonomy without using register_taxonomy () function
- AJAX call returns ‘testtest0’ instead of ‘test’ – why?
- Proper Prepare Statement for ALTER TABLE and using AFTER
- Bootstrap Error in WordPress plugin
- wp_enqueue_scripts in a plugin’s class
- Proper way to create an administration page without adding it to the menu
- Custom payment method after payment user is logged out on thank you page
- The URL of images on my website changed after being set as featured image
- extraprops override existing props
- Custom premium registration form and profile page for a WordPress Web Application
- Unexpected issue when using attachment_fields_to_edit filter
- Proper structure for first WP plugin?
- How to Disable Content Warning Dialog for Logged in users
- Load textdomain from global languages directory
- How to create custom frontend php page via plugin
- How can I add recent posts to menu like mashable
- Changing upload directory for plugin uploads only
- How do I query posts and have their related taxonomies returned in the results?
- On one of my sites a file is shown as 404 but the file IS there
- Update option hook not firing
- $_GET vs get_query_var()
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- What’s wrong in the WordPress Meta Box Generator code?
- add category id to option name when adding an option on edit_category
- esc_url, esc_url_raw or sanitize_url?
- React Plugin Settings Page Localization
- Is it within WordPress guidelines to update another plugin’s database fields from my own plugin? [closed]
- Block Development: hamburger module throwing error in save function