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

7901 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 change the background color and logo for admin login page
  • How to redirect Instant Booking Button to WooComemrce Checkout Page
  • Tehnical: Redirect to Page Not found/ White screen on listing submission or edit
  • Technical – Invoices from My Bookings

HELP CATEGORIES

  • 61. General
  • 102. Installation & Basic Setup
  • 93. Installation FAQ
  • 404. How Booking Works
  • 145. User dashboard pages
  • 20Advanced Search Options
  • 3Blog Post
  • 9Custom Page Templates
  • 18Elementor Compatibility
  • 13Email Notifications
  • 19FAQ
  • 10Menu Options
  • 26Multi-Languages - 3rd party
  • 9Owner
  • 25Property / Listing
  • 21Shortcodes
  • 11Submit Form
  • 4Supported Maps
  • 93Technical how to
  • 5Third Party plugins
  • 3Translation
  • 13Widgets
  • 2WooCommerce Payments
  • 13WP Rentals Payment
  • 77WP Rentals Theme Options

Join Us On

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