WPRentals Theme Documentation WPRentals Theme Documentation

  • Client Support
  • Video Tutorials
  • WPRentals
  • WPEstate
  • API
Home / Technical how to / How to add new fields in the user profile

How to add new fields in the user profile

9285 views

1. You need to add the html element for the new filed

To add a new field you need to edit the templates/user_profile.php file. Add the new html element but also make sure you retrieve the information in the page header (will be used to fill up the form if is anything saved ).

For example you can clone one of the existing fields

$user_mobile  =   get_the_author_meta( 'mobile' , $userID ); //in top of the page

2.Save it into database

The save of user profile is made via ajax . SO there is js code located in ajaxcalls.js at line 2238

$('#update_profile').click(function () {
var live_in,i_speak, usermobile, userpinterest, userlinkedin, usertwitter, userfacebook, profile_image_url, profile_image_url_small, firstname, secondname, useremail, userphone, userskype, usertitle, description, ajaxurl, securityprofile, upload_picture;
firstname = $('#firstname').val();
secondname = $('#secondname').val();
useremail = $('#useremail').val();.......

and a php function called wpestate_ajax_update_profile in ajax_functions.php at line 1226

function wpestate_ajax_update_profile(){
$current_user = wp_get_current_user();
$userID = $current_user->ID;
if ( !is_user_logged_in() ) {
.........

 

Make sure that in js file   you retrive the value of the filed and send it via ajax call -(again look how another field value is read and sent) . In the php file you get the value sent via ajax call

$firstname = sanitize_text_field ( wp_kses( $_POST['firstname'] ,$allowed_html) );

and save the field as a user meta

update_user_meta( $userID, 'first_name', $firstname ) ;

To reitive the new field in other pages you need to use a code like this

$user_new_field = get_the_author_meta( 'new_field' , $userID );

Technical how to

Related Articles

  • How to Make a Contact Button Open WhatsApp
  • How to add a new currency in Theme Options for payments.
  • How to Disable WordPress Image Compression and Preserve Original Quality
  • How to Change the Default Categories Icon from Listing Card Unit

HELP CATEGORIES

  • 61. General
  • 72. Installation & Basic Setup
  • 363. How Booking Works
  • 20Advanced Search
  • 17Elementor WPRentals Studio
  • 14Email Notifications
  • 23FAQ
  • 14Installation FAQ
  • 10Menu Options
  • 34Owner & Renter
  • 9Page Templates
  • 23Property / Listing
  • 22Shortcodes
  • 4Supported Maps
  • 99Technical how to
  • 5Third Party plugins
  • 4Translation & Multi Languages
  • 3WordPress Blog Post
  • 13WordPress Widgets
  • 12WP Rentals Payments
  • 79WP Rentals Theme Options
  • 26WPML & Weglot

Join Us On

Powered by WP Estate - All Rights Reserved
  • Client Support
  • Video Tutorials
  • WPRentals
  • WPEstate
  • API