Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

login

How to set different cookies for logged in admin users and logged in non admin users?

You can use current_user_can() to detect what type of user is logged in, if any, then use setcookie() and $_COOKIE to test and set the necessary cookies. function wpse_74742_stop_cache_cookie() { if (current_user_can(‘admin’)) { if (empty($_COOKIE[‘disable_cache’])) { setcookie(‘disable_cache’, 1); } } } add_action(‘init’, ‘wpse_74742_stop_cache_cookie’); This is an extremely basic example. There are a lot of details … Read more

Categories login Tags cookies, login

Can’t access login page after password reset

This could be down to a number of reasons: a) The browser you’re having problems with is saving the old password and refusing access. This is why the other browser works when logging in with the new password. Try and reset the saved password to see if this solves the issue. b) Your hosting provider … Read more

Categories login Tags login

Custom Connect to Facebook, problem logging in/logging out

The tutorial from the link I provided was destroying the facebook session after login in and creating a new account for some reason. I just had to remove $facebook->destroySession(); from both parts and now everything is working as intended. Here is the code from the tutorial with both lines commented out. if ($fbuser) { $fb_registerpage_name … Read more

Categories login Tags api, facebook, login, logout, session

How can I allow access to two user accounts using one login?

I would reverse engineer the User Switching plugin and then create a solution that works for you. Fortunately there is not a whole lot of work to do. Most of the crucial functionality is in this function: function switch_to_user( $user_id, $remember = false, $set_old_user = true ) { if ( ! $user = get_userdata( $user_id … Read more

Categories login Tags login, switch, user-access, woocommerce-offtopic

Problem with logging in WP users automatically

In the end, wp_signon() was the solution, as the cookie was apparently not set with the code I was using. I followed this solution https://gist.github.com/iandunn/8162246 to circumvent a need for password and added these functions to functions.php. I also moved the autologin code from ‘init’ to template where it executes before any headers are sent … Read more

Categories login Tags login, password, user-registration

How to implement Google reCaptcha without installing a plugin?

you can use this function i think it works properly. add_filter( ‘wp_authenticate_user’, ‘verify_recaptcha_on_login’, 10, 3 ); function verify_recaptcha_on_login($user, $password) { $secretkey = “your secret key”; if (isset($_POST[‘g-recaptcha-response’])) { $response = wp_remote_get( ‘https://www.google.com/recaptcha/api/siteverify?secret=”.$secretkey.”&response=” . $_POST[“g-recaptcha-response’] ); $response = json_decode($response[‘body’], true); if (true == $response[‘success’]) { return $user; } else { // FIXME: This one fires if … Read more

Categories login Tags authentication, captcha, code, google, login

Restrict PDF links

You cannot restrict users from downloading a file from a path using a wordpress login for various reasons, the most important is that the WP login is handled by PHP while the download is handled via Apache. That said, there is a way to achieve the result of what you’re after. What you need to … Read more

Categories login Tags content-restriction, login, pdf

Mobile users redirected to a different page on login unless linked to another post

Try this one- add_filter(‘login_redirect’, function($to, $request, $user) { if ( wp_is_mobile() && $request == null ) { return home_url().’/mobile-news’; } return $to; }, PHP_INT_MAX, 3); Not tested, but should work. Note: using a URL like this one home_url().’/mobile-news’ is not a good idea, I think. Use get_permalink( $post_id ) instead. Where $post_id is the ID … Read more

Categories login Tags login

Can’t login after URL change

Looks like the issue was because of Nginx or other caching server. Rebooting the server solved the issue! There was nothing more to do in the database or wp-config.php

Categories login Tags cookies, login

Making a client page

For the client role, use this; // Add a client user role $result = add_role( ‘client’, __( ‘Client’ ), array( ‘read’ => true, // true allows this capability ‘edit_posts’ => false, // Allows user to edit their own posts ‘edit_pages’ => false, // Allows user to edit pages ‘edit_others_posts’ => false, // Allows user to … Read more

Categories login Tags login
Older posts
Newer posts
← Previous Page1 … Page60 Page61 Page62 … Page75 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress