extra tab for account page
-
hello
I found this article to add tab to account page https://docs.ultimatemember.com/article/65-extend-ultimate-member-account-page-with-custom-tabs-content
its fine only for text I tried adding shortcode but it didn’t work
would you please advise regarding thisalso how to create tab when clicking on it sending clicker to another page
also need to know short code of the current user (UM username) to add it in specific page
and when any current user open it will find his username
with controlling the font size of itbest regards
- This topic was modified 3 years, 2 months ago by makmerghen.
-
Hello @makmerghen,
You can simply use the PHP function inside the content area. On the above documentation link where is says <!– Here goes your custom content –> replace this comment with
<?php echo do_shortcode('[yourshorcode]'); ?>
and this will show shortcode content in account tab.Hi @makmerghen
1. You can try this code – replace the line
if ( $output ) { echo $output; }
with the following:if ( $output ) { if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) { return do_shortcode( $output ); } else { return apply_shortcodes( $output ); } }
2. Create another custom account tab and then use the following code to redirect to a page.
mytab
is your unique account tab key so you need to update the key and the URL/hello-world
in the following javascript code:jQuery(document).ready(function() { jQuery(".um-account-link[data-tab='mytab']").on("click", function() { window.location.href = "/hello-world"; }); });
3. Use the following code to retrieve the username of the currently logged-in users with a shortcode:
add_shortcode("um_username","um_090621_username_shortcode"); function um_090621_username_shortcode( $atts ){ if( ! is_user_logged_in() ) return; $current_user = wp_get_current_user(); return $current_user->user_login; }
Sample usage: [um_username]
Regards,
thanks for your helping
1-regarding the the provided java script code where I can add it since when I add it in the snippets it gave me error
2- is it possible to let the tab view only for specific user role ?3- how to remove “view profile” link from account page and add in stead of it “log out link”
best regards
- This reply was modified 3 years, 2 months ago by makmerghen.
Hi @makmerghen
1. You can add the code with this plugin:
https://www.ads-software.com/plugins/insert-headers-and-footers/Just enclose the script with <script></script> tags.
2. You can replace this line:
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; }
With the following, to display the custom account tab to specific role( e.g. editor ):
add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 ); function my_custom_tab_in_um( $tabs ) { if( um_user("role") == "editor" ){ $tabs[800]['mytab']['icon'] = 'um-faicon-pencil'; $tabs[800]['mytab']['title'] = 'My Custom Tab'; $tabs[800]['mytab']['custom'] = true; } return $tabs; }
3. You will need to copy the Account template and then override it via theme so you can modify the template to change the links. The template is located in
/plugins/ultimate-member/templates/account.php
Please see this doc: https://docs.ultimatemember.com/article/1516-templates-map
Regards,
thank you for helping
regarding added link to tab
I added the java script in header but something strange happened
the link on tab work only in desktop
when I clicked on the tab in mobile it didn’t redirct me to the added linkplease advise
Hi @makmerghen
Try this one:
jQuery(document).ready(function() { jQuery("a[data-tab='mytab']").on("click touchend", function() { window.location.href = "/hello-world"; }); });
Regards,
thank a lot its work now
- This reply was modified 3 years, 2 months ago by makmerghen.
when trying the code mention in your page to add more than tab I created 2 snippets in code snippets plugin and I add the jquery you gave
in the second tab I change all “mytab” to be “mytab2”
the result
that only the second tab is appear
for the first one code snippets disabled it and I can not enable itso please advise
Hi @makmerghen
Please provide the codes here so we can review them. Please enclose the code with the CODE tags. You will see “CODE” when you write a response with the textarea.
Your code starts here and code ends here
https://drive.google.com/file/d/1N85L1bQWZvEY4xcJ6kpzqI3tTPXDCnu3/view?usp=sharing
Regards,
/* 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[10]['mytab']['icon'] = 'um-faicon-pencil'; $tabs[10]['mytab']['title'] = 'Logout'; $tabs[10]['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"> <?php echo do_shortcode('[us]'); ?> </div> <?php $output .= ob_get_contents(); ob_end_clean(); return $output; }
I change all mytab to be mytab2
regards
Hi @makmerghen
Have you tried changing the ID from 10 to 11?
$tabs[10]['mytab']['icon'] = 'um-faicon-pencil'; $tabs[10]['mytab']['title'] = 'Logout'; $tabs[10]['mytab']['custom'] = true;
Are you trying to create 2 custom account tabs? I’m confused about your issue.
Regards,
yes one is 10 and the other 800
and yes I am trying to create 2 tabs so I created 2 snippets using code snippets plugin
only one worked
and the other snippets refused to be active by code snippetsregards
Hi @makmerghen
Can you please provide the second tab that doesn’t show in the Account Form?
Regards,
/* add new tab called "mytab2" */ add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 ); function my_custom_tab_in_um( $tabs ) { $tabs[800]['mytab2']['icon'] = 'um-faicon-pencil'; $tabs[800]['mytab2']['title'] = 'My Custom Tab'; $tabs[800]['mytab2']['custom'] = true; return $tabs; } /* make our new tab hookable */ add_action('um_account_tab__mytab2', 'um_account_tab__mytab2'); function um_account_tab__mytab2( $info ) { global $ultimatemember; extract( $info ); $output = $ultimatemember->account->get_tab_output('mytab2'); if ( $output ) { echo $output; } } /* Finally we add some content in the tab */ add_filter('um_account_content_hook_mytab2', 'um_account_content_hook_mytab2'); function um_account_content_hook_mytab2( $output ){ ob_start(); ?> <div class="um-field"> <?php echo do_shortcode('[affiliate_area]'); ?> </div> <?php $output .= ob_get_contents(); ob_end_clean(); return $output; }
- This reply was modified 3 years, 2 months ago by makmerghen.
Hi @makmerghen
Sorry for the late response. I tried the following Custom Tab 2 and it works on my end. Please try the following:
add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um2', 100 ); function my_custom_tab_in_um2( $tabs ) { $tabs[800]['mytab2']['icon'] = 'um-faicon-pencil'; $tabs[800]['mytab2']['title'] = 'My Custom Tab 2'; $tabs[800]['mytab2']['custom'] = true; return $tabs; } /* make our new tab hookable */ add_action('um_account_tab__mytab2', 'um_account_tab__mytab2'); function um_account_tab__mytab2( $info ) { global $ultimatemember; extract( $info ); $output = $ultimatemember->account->get_tab_output('mytab2'); if ( $output ) { echo $output; } } /* Finally we add some content in the tab */ add_filter('um_account_content_hook_mytab2', 'um_account_content_hook_mytab2'); function um_account_content_hook_mytab2( $output ){ ob_start(); ?> <div class="um-field"> <?php echo do_shortcode('[affiliate_area]'); ?> </div> <?php $output .= ob_get_contents(); ob_end_clean(); return $output; }
Regards,
- The topic ‘extra tab for account page’ is closed to new replies.