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

Find out how many times the user has logged in

I don’t think so. You will need to do something like this (untested):

add_action("wp_login", "my_login_function");

function my_login_function($username){
   $userdata = get_user_by('login', $username);
   $n = get_user_meta($userdata->ID, "my_login_counter", true);
   if (! is_numeric($n)) $n = 0;
   $n = intval($n) + 1;
   update_user_meta($userdata->ID, "my_login_counter", $n);
}

Related Posts:

  1. Changing user_nicename
  2. User management system similar to wordpress one?
  3. Extract all users along with yoast metadata description
  4. Custom user query – orderby meta_key (that may not exist)
  5. How can I show user’s privileges in MySQL?
  6. MySQL Error: : ‘Access denied for user ‘root’@’localhost’
  7. MySQL Error: : ‘Access denied for user ‘root’@’localhost’
  8. How to use mysqli_query() in PHP?
  9. Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
  10. Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
  11. ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
  12. Column count doesn’t match value count at row 1
  13. ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
  14. MySQL string replace
  15. Cannot add or update a child row: a foreign key constraint fails
  16. ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
  17. String concatenation in MySQL
  18. What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? [duplicate]
  19. Cannot add or update a child row: a foreign key constraint fails
  20. MySQL Error “Operand should contain 1 column”
  21. How to use MySQL DECIMAL?
  22. Access denied for user ‘root@localhost’ (using password:NO)
  23. Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (38)
  24. How to make MySQL table primary key auto increment with some prefix
  25. Access denied for user ‘root@localhost’ (using password:NO)
  26. MySQL ERROR 1290 (HY000) –secure-file-priv option
  27. MySQL error 2006: mysql server has gone away
  28. Which MySQL data type to use for storing boolean values
  29. sql query with multiple where statements
  30. ERROR 2003 (HY000): Can’t connect to MySQL server on localhost (10061)
  31. ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
  32. Cannot delete or update a parent row: a foreign key constraint fails
  33. Cannot delete or update a parent row: a foreign key constraint fails
  34. ERROR 2003 (HY000): Can’t connect to MySQL server on localhost (10061)
  35. MySQL server startup error ‘The server quit without updating PID file’
  36. Rename a column in MySQL
  37. Configuration System Failed to Initialize
  38. “INSERT IGNORE” vs “INSERT … ON DUPLICATE KEY UPDATE”
  39. Cannot delete or update a parent row: a foreign key constraint fails
  40. MySQL server startup error ‘The server quit without updating PID file’
  41. How do I restore a dump file from mysqldump?
  42. Syntax error due to using a reserved word as a table or column name in MySQL
  43. ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
  44. MySQL root password change
  45. Installation of MySQL for Visual Studio 1.2.8 failed
  46. Not unique table/alias
  47. How do I import an SQL file using the command line in MySQL?
  48. PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused
  49. #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
  50. MySQL ERROR 1045 (28000): Access denied for user ‘bill’@’localhost’ (using password: YES)
  51. Your password does not satisfy the current policy requirements
  52. How do I quickly rename a MySQL database (change schema name)?
  53. What does SQL Select symbol || mean?
  54. Install mysql-python (Windows)
  55. MySQL: Access denied for user ‘test’@’localhost’ (using password: YES) except root user
  56. PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused
  57. SQL – Update multiple records in one query
  58. Mysql: Setup the format of DATETIME to ‘DD-MM-YYYY HH:MM:SS’ when creating a table
  59. What is the definition of cardinality in SQL
  60. How to restart remote MySQL server running on Ubuntu linux?
  61. Authentication plugin ‘caching_sha2_password’ cannot be loaded
  62. MySQL DROP all tables, ignoring foreign keys
  63. #1055 – Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by
  64. When to use SELECT … FOR UPDATE?
  65. Host ‘xxx.xx.xxx.xxx’ is not allowed to connect to this MySQL server
  66. Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
  67. Setting up foreign keys in phpMyAdmin?
  68. Select from multiple tables without a join?
  69. PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP
  70. ERROR 1396 (HY000): Operation CREATE USER failed for ‘jack’@’localhost’
  71. SQL Query Where Field DOES NOT Contain $x
  72. Create a new database with MySQL Workbench
  73. Duplicating a MySQL table, indices, and data
  74. Disable ONLY_FULL_GROUP_BY
  75. what does “/index.php?admin/admin_dashboard” in my url mean
  76. Column ‘user_id’ in field list is ambiguous
  77. How to join two tables by multiple columns in SQL?
  78. How to get size of mysql database?
  79. mysql Foreign key constraint is incorrectly formed error
  80. Database sharding vs partitioning
  81. Selecting data from two different tables without using joins
  82. MySQL WHERE IN ()
  83. Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
  84. Is there an SQLite equivalent to MySQL’s DESCRIBE [table]?
  85. ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111)
  86. SQL – Update multiple records in one query
  87. Difference between VARCHAR and TEXT in MySQL
  88. mysql is not recognised as an internal or external command,operable program or batch
  89. 1052: Column ‘id’ in field list is ambiguous
  90. Escape string Python for MySQL
  91. 1052: Column ‘id’ in field list is ambiguous
  92. MySQL Error 1093 – Can’t specify target table for update in FROM clause
  93. MySQL: Invalid use of group function
  94. SELECT list is not in GROUP BY clause and contains nonaggregated column …. incompatible with sql_mode=only_full_group_by
  95. Host ‘xxx.xx.xxx.xxx’ is not allowed to connect to this MySQL server
  96. difference between primary key and unique key
  97. mysqladmin: connect to server at ‘localhost’ failed
  98. mysql update multiple columns with same now()
  99. Mysql command not found in OS X 10.7
  100. SELECT * FROM multiple tables. MySQL
Categories MySQL Tags login, mysql, users
Blog has an infinite redirect loop
if/Else have_posts Else fails to echo message to page

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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • 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