WP Rentals Help WP Rentals Help

  • 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

8544 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 Disable WordPress Image Compression and Preserve Original Quality
  • How to Change the Default Categories Icon from Listing Card Unit
  • How to change the background color and logo for admin login page
  • How to redirect Instant Booking Button to WooComemrce Checkout Page

HELP CATEGORIES

  • 71. General
  • 102. Installation & Basic Setup
  • 393. How Booking Works
  • 20Advanced Search
  • 19Elementor Free & WP Rentals Studio
  • 13Email Notifications
  • 10FAQ
  • 14Installation FAQ
  • 10Menu Options
  • 27Multi-Languages - 3rd party
  • 32Owner & Renter
  • 9Page Templates
  • 24Property / Listing
  • 21Shortcodes
  • 4Supported Maps
  • 97Technical how to
  • 5Third Party plugins
  • 3Translation
  • 3WordPress Blog Post
  • 13WordPress Widgets
  • 12WP Rentals Payments
  • 78WP Rentals Theme Options

Join Us On

Powered by WP Estate - All Rights Reserved
  • Client Support
  • Video Tutorials
  • WpRentals
  • WpEstate
  • API