-
-
Save ultimatemember/f7eab149cb33df735b08 to your computer and use it in GitHub Desktop.
/* add new tab called "mytab" */ | |
add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 ); | |
function my_custom_tab_in_um( $tabs ) { | |
$tabs[800]['mytab']['icon'] = 'um-faicon-pencil'; | |
$tabs[800]['mytab']['title'] = 'My Custom Tab'; | |
$tabs[800]['mytab']['custom'] = true; | |
return $tabs; | |
} | |
/* make our new tab hookable */ | |
add_action('um_account_tab__mytab', 'um_account_tab__mytab'); | |
function um_account_tab__mytab( $info ) { | |
global $ultimatemember; | |
extract( $info ); | |
$output = $ultimatemember->account->get_tab_output('mytab'); | |
if ( $output ) { echo $output; } | |
} | |
/* Finally we add some content in the tab */ | |
add_filter('um_account_content_hook_mytab', 'um_account_content_hook_mytab'); | |
function um_account_content_hook_mytab( $output ){ | |
ob_start(); | |
?> | |
<div class="um-field"> | |
<!-- Here goes your custom content --> | |
</div> | |
<?php | |
$output .= ob_get_contents(); | |
ob_end_clean(); | |
return $output; | |
} |
How to add "logout" link to the account page?
@ayhanmalkoc To add a custom logout link, please do the following.
- In your child theme's functions.php file (I am assuming you have a child theme set up, if not, I recommend you do so), paste the following code
/**
* UM Custom Logout Tab
*/
add_filter('um_account_page_default_tabs_hook', 'um_logout_tab', 100 );
function um_logout_tab( $tabs ) {
$tabs[800]['logout']['icon'] = 'um-faicon-sign-out';
$tabs[800]['logout']['title'] = 'Logout';
$tabs[800]['logout']['custom'] = true;
$tabs[800]['logout']['show_button'] = false;
return $tabs;
}
/* Make logout tab hookable */
add_action('um_account_tab__logout', 'um_account_tab__logout');
function um_account_tab__logout( $info ) {
global $ultimatemember;
extract( $info );
$output = $ultimatemember->account->get_tab_output('logout');
if ( $output ) { echo $output; }
}
/* Add some content in the tab */
add_filter('um_account_content_hook_logout', 'um_account_content_hook_logout');
function um_account_content_hook_logout( $output ){
ob_start();
?>
<div class="um-field">
<!-- Custom content -->
</div>
<?php
$output .= ob_get_contents();
ob_end_clean();
return $output;
}
-
In your child theme
(wp-content/themes/your-child-theme/)
, create a new folder called "ultimate-member" and within that new folder, create another folder called "templates". So your path should now be(wp-content/themes/your-child-theme/ultimate-member/templates)
. -
Navigate to the Ultimate Member plugin folder
(wp-content/plugins/ultimate-member/templates)
and copy the file named "account.php". Then, go back to the "templates" folder you just created in your child theme in step 2 and paste the account.php file in there. Wordpress will now use the new account.php file in your child-theme, instead of the original one in the plugin folder, when rendering an account page. -
Following @mcknightd steps earlier
Open the new account.php file (in your child theme folder), and find the line near the end with
do_action( 'um_after_account_page_load' ); ?>
. Paste the following code directly before that line:
add_action( 'um_after_account_page_load', 'override_a_tab', 10 );
function override_a_tab() {
?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('[data-tab="logout"]').prop('disabled', true).click(function(e){
e.preventDefault();
window.location.href="https://yoursite.com/logout";}); // CHANGE THIS TO YOUR LOGOUT URL
})
</script>
<?php
}
Doing this will disable that tab's normal delegated behaviour and tell it to it go to that URL instead, which if you change it to your logout URL, will hence logout the user out when the tab is clicked.
Hello,
I have an issue with my account page that is very disturbing.
I have a new tab called monBeneficiaire in which I want to edit some fields (lien-de-parente in my example).
I tried both code of @hedgehog90 and @mcknightd but it is the same.
When I load my page account, I am in the tab general. If I made change directly and press the update button, my updates are commited.
But if I try to change tab like if I go in the password tab then come back to the general tab, I can still edit my fields but when I update, nothing change. Basically my updates are not commited if I click on any of my tab (even general).
I've been throught the whole conversation of this page but It seems that no one had the same issue.
Does someone have any clues of what happens ?
Hello @hemnathmouli @Ferdinand1945 @hirenshah @ghmercado @jkester1986 and everyone... Please how do i disable the button that is automatically added to the new custom account tab?
Image here >> https://ibb.co/RvXLMFv
Is there a way to return the user to their account page after saving details from a custom tab? It currently gives a 404 when it tries to return to the custom tab.
How do I integrate zoom online meeting platform with UM plugin?
Thanks in advance.
Could we add a submenu within the custom tab? A sub-custom tab that is.
How to add "logout" link to the account page?