WordPress Developer Ukraine, Kyiv
Get the current logged-in user data in WordPress

Get the current logged-in user data in WordPress

Get the current user in WordPress: wp_get_current_user() and friends Showing the name of the logged-in user, loading their own data, hiding a block from guests: almost every project needs the current user. WordPress has a small set of functions for it, and the only real pitfall is calling them too early, before WordPress knows who…
WordPress User Registration Hooks: Validate Custom Fields, Save Meta, and Send Welcome Email

WordPress User Registration Hooks: Validate Custom Fields, Save Meta, an ...

User registration hooks: validate extra fields, save them, send a welcome email The registration form on wp-login.php?action=register asks only for a username and an email. Three hooks let you extend it: register_form prints extra fields, the registration_errors filter validates them and can stop the registration, and user_register runs after the account was created. With profile_update…
Add Custom Fields to the WordPress User Profile with User Meta

Add Custom Fields to the WordPress User Profile with User Meta

Add custom fields to the WordPress user profile User data that WordPress does not know, like a phone number, a department or a preference, is stored in user meta, the same key-value storage posts have. To let users and administrators edit it, add fields to the profile screen with two display hooks and save them…
How to Get User Location by IP Address in WordPress

How to Get User Location by IP Address in WordPress

How to get a user’s location by IP address in WordPress Geolocation lets you show or hide content depending on the visitor’s country: region-restricted products, localised promotions, country-specific notices. The approach has three steps: get the visitor’s IP, ask a geolocation service which country it belongs to, and act on the result.