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

Adding a login form that concatenates three fields into a username

If you create the user by passing the values entered to a function that combines them, then you can call it from another that calls wp_insert_user. Then you can save the username/pass as needed, and use the same function and form when preparing them for WP to check on log-in.
All of the code below is intended for demonstration only. Can’t stress that enough. Definitely look into nonce and validating registration.

Again, this is ONLY a demo of the idea to point in the general direction.

<form>
    <input type="text" name"value1" />
    <input type="text" name"value2" />
    <input type="text" name"value3" />
</form>

Then we have a function to handle the combining of the entries:

<?php 
function getting_posted_values() {
    if(isset($_POST['value1']) && (isset($_POST['value2']) && (isset($_POST['value3']) {
       $value1 = $_POST['value1'];
       $value2 = $_POST['value2'];
       $value3 = $_POST['value3'];
       $new_value = $value1 . $value2 . $value3;
    }
  return $new_value;
 }

Then a hooked function – (for instance if you used Contact Form 7 to manage the form, you could hook wpcf7_before_send_mail and get access to the post object.) – could call the function below and build the new user:

function build_a_new_user($posted_form) {
    $new_value = getting_posted_values($posted_form);
    $userdata = array(
          'user_login'   => $new_value,
          'user_pass'    => $new_value, //normally: wp_generate_password( 12, false );
          'user_email'   => //note: not sure but may be required?
          'nickname'     => $new_value,
          'display_name' => $new_value,
          'first_name'   => $new_value,
          'last_name'    => $new_value,
          'role'         => 'subscriber'
         );
     wp_insert_user($userdata);

}

wp_insert_user() is documented here.

More on handling custom registration here.

For Logging In

Your form with values 1,2,3 would run getting_post_values again by being called within another function that is hooked to log in somehow. Perhaps the login_form_defaults filter that can edit the args array for the form. The follow is complete speculation as a non-working example.

But the idea is that if you can pass those values to WP’s normal process (perhaps via the authenticate filter mentioned in your linked example?) as the user/pass, you can forgo doing the checking yourself.

function log_in_handler($posted_form) {
    $pass_and_username = getting_posted_values($posted_form);
    $args_array = array(
       'username_id' => $pass_and_username, 
       'password' => $pass_and_username);        
}

It’s definitely an interesting endeavor. Hope that helps.

Related Posts:

  1. Change the login button on the login page
  2. Custom ReCaptcha Login
  3. What is the proper way to apply the login_form_bottom filter?
  4. How to override wp-login.php
  5. Remove Links from Login page
  6. setting a specific home page for logged in users
  7. Change “logged in” link in (you must be logged in to post a comment)
  8. Redirect to requested page after (custom) login
  9. Customizing the default logout page of WordPress
  10. How do I remove the eye icon that shows visibility on login screen and reset password screen
  11. Custom Login and Registration form in Ajax
  12. Last time a user logged in
  13. How can I allow access to multiple users, using the same login, at the same time?
  14. WordPress custom login page
  15. Properly customizing login/register form
  16. How to add an extra variable to login and authenticate it?
  17. Login/Logout Session Sharing – Multiple WordPress Installations
  18. Custom login with external provider iframe and data object
  19. Deep customization of wp-login.php
  20. User can not login
  21. Lost password empty field error redirect to custom login
  22. Custom Log In Screen – Disable password recovery [duplicate]
  23. Multi-site User Sessions
  24. A truely custom login page?
  25. Switch between WordPress websites easy for an end user
  26. Lost password and back to blog in same line
  27. I w’d like to know If there are simple solutions to integrate other CMSs to wordpress
  28. Restrict content access to logged in users
  29. Custom login and registration forms
  30. URL and Site title outputting on Login page
  31. Is it possible to integrate a custom login feature with wordpress?
  32. How to change the login page without a plugin and not only customizing logo and text around the form?
  33. Removing “Failed” query argument upon successful login
  34. Validate user login in php
  35. how to change the url rediction of the woocommerce login page of the flatsome theme for my own in wordpress?
  36. How to change Login default blue admin color?
  37. Latest update broke my custom login CSS
  38. Trouble with custom login page
  39. Wrap WordPress Login Form in custom Div
  40. Custom login doesn’t stay
  41. Check get_post value after wp-admin login
  42. where can i find the login page in wordpress and add my header to it
  43. Change the default WordPress image on the dashboard login to a custom image [duplicate]
  44. Pass the post ID
  45. Show Site Name on WP login screen
  46. how to manage Session in WordPress using custom login?
  47. Redirect all pages to the custom login page except for the registration page
  48. How to stop login for SPECIFIC users BEFORE a specified date
  49. Must I rewrite the whole login form or can I jsut do a part
  50. How to: Easily Move a WordPress Install from Development to Production?
  51. Is there a flowchart for WordPress loading sequence?
  52. Essential technical features for high-end WordPress web hosting? [closed]
  53. How to remove admin menu pages inserted by plugins?
  54. How to put logs in WordPress
  55. How to get the Date Format and Time Format settings for use in my template?
  56. Where are Additional CSS files stored
  57. Best Practices for Regression Testing WordPress Websites?
  58. Remove wrapping div and ul from output of wp_nav_menu
  59. What Is The Use Of map_meta_cap Filter?
  60. get post author id outside loop
  61. Custom Walker: how to get ID in function start_lvl
  62. Creative uses of WordPress [closed]
  63. How to *remove* a parent theme page template from a child theme?
  64. How do I make my child theme re-apply the settings that were customised when its parent was active?
  65. Multiple Inputs in a Customizer Control
  66. New WP_Customize API – how does it work under the hood?
  67. Embedding a SOAP Client into a WordPress Plugin?
  68. Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
  69. Update widget form after drag-and-drop (WP save bug)
  70. Data sanitization: Best Practices with code examples
  71. How to benchmark a WordPress installation? [closed]
  72. Should I delete the default themes?
  73. Moving WP install from local to live, what about wp_posts GUID?
  74. Modified wp.media.view.Settings.Gallery in Backbone JS, but editing doesn’t work
  75. Running Gutenberg React in Development Mode
  76. Prevent WordPress from automatically installing a new theme each year
  77. Can we use one WordPress installation for multiple databases, domains and content directories
  78. Is there a blank theme framework compatible with WP 3.0? [closed]
  79. Plugin SVN & update API – how are plugins identified?
  80. Users with custom roles not showing in post author select box
  81. How to use more than 256MB of memory in the admin?
  82. How do register_sidebar() and get_sidebar() work together?
  83. How do you get formatted content of a post using the WordPress API?
  84. Localization: I want the backend: english and frontend in defined language
  85. Are there any forks of WordPress (and what is different about them)?
  86. How to Change 404 page title
  87. Make Custom Metaboxes Collapse by Default
  88. WordPress Paginate $wpdb->get_results
  89. Custom maintenance page
  90. Add button to TinyMCE bar without creating a plugin
  91. Why do I get the timeout warning?
  92. How to add a new product type on woocommerce product types? [closed]
  93. How to include own css on wordpress tinymce editor?
  94. How to disable page delete
  95. Adding extra authentication field in login page
  96. add button to post edit page when post_status=publish
  97. how to override woocommerce specific loop or archive-product.php [closed]
  98. Modify existing plugin function using filter (without modifying the plugin directly)
  99. Rename UPLOADS folder with custom WP_CONTENT_DIR
  100. WordPress hook before inserting post into database
Categories customization Tags customization, login
pre_get_posts query between 2 dates (date stored in custom post meta)
Looking for the best solution to build this Blog structure? Picture attached?

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