ph91.de
  • Home
  • About me
  • Categories
    • Software Development
    • New Zealand
    • Music
    • Tech & IT
    • Sports
    • Dublin
    • Junk
  • Contact
  • Disclaimer
ph91.de
ph91.de
  • Home
  • About me
  • Categories
    • Software Development
    • New Zealand
    • Music
    • Tech & IT
    • Sports
    • Dublin
    • Junk
  • Contact
  • Disclaimer
  • Software Development

Gravity Forms – User Registration fix

  • 17. September 2017
  • Philipp

For the registration of our new users on speed-kini.de, we use the very cool Gravity Forms Plugin. It all worked quite fine until new users did not have a first name, last name or display name specified. I’ve had the hope that there will be an update, which may fix this problem, but there hasn’t been one yet. So I decided to fix it manually by updating the new WordPress user object:

Needed Action

Gravity forms provide gform_user_registered. It has the entry, feed, and user_id as parameters:

gform_user_registered usage

Custom Code

public static function userRegistered( $user_id, $feed, $entry, $user_pass ) {
   $firstName = $entry[ $feed['meta']['first_name'] ];
   $lastName  = $entry[ $feed['meta']['last_name'] ];
   $userName  = $entry[ $feed['meta']['username'] ];

   // Fix registration
   $res = wp_update_user( array(
      'ID'           => $user_id,
      'first_name'   => $firstName,
      'last_name'    => $lastName,
      'display_name' => $firstName . " " . $lastName
   ) );
}

This works fine for me  😎

 

Related Topics
  • first_name
  • fix
  • Gravity Forms
  • last_name
  • user registration
  • username
Philipp

Previous Article
  • Tech & IT

Boosting productivity with Trello

  • 6. September 2017
  • Philipp
View Post
Next Article
  • Music

Gilles Peterson words & music w/ Dan Snaith

  • 8. October 2017
  • Philipp
View Post

Leave a Reply

Your email address will not be published. Required fields are marked *

Dev profiles
  • BitBucket
  • Github
  • Stackoverflow
Side Projects
  • NMF
  • Speed-kini.de
  • Sudoku Solver
  • Windwarner
Archive
ph91.de
Blog by Philipp Schreitmüller

Input your search keywords and press Enter.