I think you’re looking for the filter um_after_user_account_updated
which you can find here.
Below is my example which is working for me. I only started using it yesterday so can’t tell if this is the best way.
First add a new tab:
/**
* Add account tabs
*
* @param $tabs
*
* @return mixed
*/
function beee_custom_account_tabs( $tabs ) {
$tabs[ 250 ][ 'settings' ][ 'icon' ] = 'um-faicon-wrench';
$tabs[ 250 ][ 'settings' ][ 'title' ] = __( 'Settings', 'beee' );
$tabs[ 250 ][ 'settings' ][ 'custom' ] = true;
$tabs[ 250 ][ 'settings' ][ 'show_button' ] = true;
$tabs[ 250 ][ 'settings' ][ 'submit_title' ] = __( 'SAVE', 'beee' );
return $tabs;
}
add_filter( 'um_account_page_default_tabs_hook', 'beee_custom_account_tabs', 100 );
Then call the tab content:
/**
* Call output tab settings
*
* @param $info
*/
function beee_account_tab_settings( $info ) {
global $ultimatemember;
extract( $info ); // this one is probably redundant
$output = $ultimatemember->account->get_tab_output( 'settings' );
if ( $output ) {
echo $output;
}
}
add_action( 'um_account_tab__settings', 'beee_account_tab_settings' );
Output the tab content:
/**
* Output tab settings
*
* @param $output
*
* @return string
*/
function beee_account_content_hook_settings( $output ) {
ob_start();
?>
<div class="um-field">
<p>
<?php _e( 'Here you can find some general settings.', 'beee' ); ?>
</p>
<p>
<label for="um_account_instagram">Your Instagram name</label>
<input type="text" name="um_account_instagram" id="um_account_instagram" class="" value="" placeholder="@yourname"/>
</p>
<p>
<label for="um_account_twitter">Your Twitter name</label>
<input type="text" name="um_account_twitter" id="um_account_twitter" class="" value="" placeholder="@yourname"/>
</p>
<p>
<label for="um_account_lanuage">Default language</label>
<br/>
<select id="um_account_lanuage" name="um_account_lanuage">
<option value="en"><?php _e( 'English', 'beee' ); ?>
<option value="nl"><?php _e( 'Dutch', 'beee' ); ?>
<option value="de"><?php _e( 'German', 'beee' ); ?>
</select>
</p>
</div>
<?php
$output .= ob_get_contents();
ob_end_clean();
return $output;
}
add_filter( 'um_account_content_hook_settings', 'beee_account_content_hook_settings' );
Then after the account is saved, you can access the $_POST data and do whatever you need to do with the data.
/**
* Do stuff after "Update Account"
*
* @param $user_id
* @param $changes
*/
function beee_after_user_account_updated( $user_id, $changes ) {
if ( ! empty( $_POST[ 'um_account_instagram' ] ) ) {
update_user_meta( $user_id, 'um_account_instagram', $_POST[ 'um_account_instagram' ] );
}
}
add_action( 'um_after_user_account_updated', 'beee_after_user_account_updated', 10, 2 );
Hope this helps…
-
This reply was modified 5 years, 10 months ago by Beee. Reason: fix link