Add custom user profile fields

Hello
I'd like to add custom user profile fields to the ones that A+ plugin already added.
How can I do this?

Thanks

Luis

  • Adam Czajczyk

    Hello Luis,

    An Appointments+ plugin does not "replace" default WP registration/login procedure and there's currently no feature that would let you add any additional fields to user's profile. The most flexible solution in my opinion would be to use BuddyPress plugin and it's X-Profile fields feature for this.

    Take a look here please:

    https://buddypress.org/

    https://codex.buddypress.org/component/xprofile-2/

    That's a really powerful but easy to setup and use plugin and it plays very well with our plugins. In fact some plugins of ours such as "Membership 2" for example feature built-in integration for BuddyPress. Appointments+ is compatible with BuddyPress as well.

    I hope that helps!

    Best regards,
    Adam

  • Milan

    Hello @Luis,

    Hope you are doing well. :slight_smile:

    Seems like my colleague @Adam Czajczyk understand you are talking about default wordpress provided user profile fields. But if we talk about appointments generated custom user profile fields then this is possible but it will require some core file editing to be done. If you are ready to edit core plugin files then here are the steps through which you can make this happen. But dear member please keep in mind that changes to core files won't be preserved when plugin gets updated. So always take your changed file's backup before attempting update process. :slight_smile:

    Steps through which you'll be able to add custom fields to registration form. :slight_smile:

    #1) Open file /wp-content/plugins/appointments/admin/class-app-admin.php in your favorite editor.
    #2) Navigate to line no 200. You will see something like,

    <table class="form-table">
    			<tr>
    				<th><label><?php _e("My Name", 'appointments'); ?></label></th>
    				<td>
    					<input type="text" style="width:25em" name="app_name" value="<?php echo get_user_meta( $profileuser->ID, 'app_name', true ) ?>" <?php echo $is_readonly ?> />
    				</td>
    			</tr>
             .
             .
             .

    Now just copy one of <tr> element and paste it anywhere within "table" element. Something like this,

    <table class="form-table">
    			<tr>
    				<th><label><?php _e("My Name", 'appointments'); ?></label></th>
    				<td>
    					<input type="text" style="width:25em" name="app_name" value="<?php echo get_user_meta( $profileuser->ID, 'app_name', true ) ?>" <?php echo $is_readonly ?> />
    				</td>
    			</tr>
    
    <!-- This tr element is copied from above one -->
    			<tr>
    				<th><label><?php _e("My Test Field", 'appointments'); ?></label></th>
    				<td>
    					<input type="text" style="width:25em" name="my_test_field" value="<?php echo get_user_meta( $profileuser->ID, 'my_test_field', true ) ?>" <?php echo $is_readonly ?> />
    				</td>
    			</tr>
    <!-- please review modification I've done with this element -->

    Once you do this, you'll need to change label inner text plus, name and value property of input element. Please refer above example and see how I've changed those properties.

    Now here just keep in mind that whatever name you chose for input element, should not have spaces in between.

    #3) Now navigate to line no. 39 of same file.
    #4) Now based on name you've chosen for your custom profile fields, you'll need to modify below code accordingly. After modification add below code after line no 39.

    if ( isset( $_POST['my_test_field'] ) )
    			update_user_meta( $profileuser_id, 'my_test_field', $_POST['my_test_field'] );

    I've attached customized file after some modifications, feel free to play with it. :slight_smile:

    Let me know if you need help with something else. :slight_smile:

    Kind Regards,
    Milan Savaliya.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.