Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Extending Ultimate Member Profile Menu using Hooks
/* First we need to extend main profile tabs */
add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 );
function add_custom_profile_tab( $tabs ) {
$tabs['mycustomtab'] = array(
'name' => 'My custom tab',
'icon' => 'um-faicon-comments',
);
return $tabs;
}
/* Then we just have to add content to that tab using this action */
add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default');
function um_profile_content_mycustomtab_default( $args ) {
echo 'Hello world!';
}

Anyway to change "mycustomtab" in the URL ?profiletab=mycustomtab?

I tried changing it in the code but the tab disappeared afterwards.

Antviss commented Nov 22, 2015

@peteratomic You need to change "mycustomtab" wherever it appears in the code above.

E.G.:

add_action('um_profile_content_mycustomtabdefault', 'um_profile_contentmycustomtabdefault');
function um_profile_content
mycustomtab_default( $args ) {

eyaal commented Nov 27, 2015

Hello,
Which page should the customtab code be added to in order to at a custom tabe to my profile tab?

Regards,
Eyaalada Akari

tajbarr commented Feb 11, 2016

I have added 5 custom tabs but now want to add in some custom Ultimate Member Forms how would I do this in the content space,

add_action('um_profile_content_tab1_default', 'um_profile_content_tab1_default');
function um_profile_content_tab1_default( $args ) {
echo 'I want the for to go here';
}

Do I have to create a new file and write this code or I have write this in um-profile.php in templates folder? I am new to this please help me!!

Do I have to create a new file and write this code or I have write this in um-profile.php in templates folder? I am new to this please help me!!

Hi,
I have two questions:

  1. in which file do I have to add the code to get a custom tab?
  2. I want to add a custom tab which leads to an URL (e.g. /user/edit.php) when I click on it - how do I do that?
    Thank you very much!

zeecom commented Apr 21, 2016

Hello,
does anyone know how to add arbitrary code to a custom tab on the Profile page? I've been able to do that with the Account page, but can't figure it out for the Profile page... i guess it doesn't help that I'm not a programmer... :)

I've used code from this example:
http://docs.ultimatemember.com/article/65-extend-ultimate-member-account-page-with-custom-tabs-content for the Account page.

Now I'm using this example:
http://docs.ultimatemember.com/article/51-custom-profile-tab-example-showing-user-pages
to try to add the same HTML code on the Profile page... using the sample code in above mentioned pages, I'm trying to apply this:

/* 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;
}

to this:

/* Tell the tab what to display */
add_action('um_profile_content_pages_default', 'um_profile_content_pages_default');
function um_profile_content_pages_default( $args ) {
    global $ultimatemember;
    $loop = $ultimatemember->query->make('post_type=page&posts_per_page=10&offset=0&author=' . um_profile_id() );
    while ($loop->have_posts()) { $loop->the_post(); $post_id = get_the_ID();
    ?>

        <div class="um-item">
            <div class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
        </div>

    <?php
    }
}

Thanks!

jakeols commented Sep 21, 2016

Tab is disappearing when I change it from anything other than 'mycustomtab', similar to what @peteratomic reported. I changed all references where mycustomtab was called.

Is this expected behavior?

Edit: apparently de-activating and reactivating plugin fixes this problem..

@Psychopomp777

  1. You add the code in your functions.php file at the bottom.
  2. I am trying to figure this out right now. (Does anyone have the answer to this??)

is there anyone can help me with where exactly i would add that code, please??

@tajbarr Could you tell me how you made 5 custom tabs? Did you change the code or just paste it 5 times? anyone knows how to make more than 1 tabs?

elias1435 commented May 23, 2017

Hello,
anybody can help me how can I display profile Form to the tab. Although I use shortcodes, it's showing the Profile form but when a user going to "Delete Account" it's not working ... I was check problem is the shortcode. here is the code

/* 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]['makeedit']['icon'] = 'um-faicon-pencil';
$tabs[800]['makeedit']['title'] = 'Make An Edit';
$tabs[800]['makeedit']['custom'] = true;
return $tabs;
}

/* make our new tab hookable */

add_action('um_account_tab__makeedit', 'um_account_tab__makeedit');
function um_account_tab__makeedit( $info ) {
global $ultimatemember;
extract( $info );

$output = $ultimatemember->account->get_tab_output('makeedit');
if ( $output ) { echo $output; }

}

/* Finally we add some content in the tab */

add_filter('um_account_content_hook_makeedit', 'um_account_content_hook_makeedit');
function um_account_content_hook_makeedit( $output ){
ob_start();
?>

<div class="um-field">
          <div class="custom-profile-update">
               <?php echo do_shortcode('[ultimatemember form_id=4658]'); ?>
          </div>
</div>		

You put this code into your function.php file. Also it is possible to use child themes' functions.php file.

eminsafa commented Jun 13, 2017

By the way you can add one more tab with these codes:

add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 );
function add_custom_profile_tab( $tabs ) {

	$tabs['mycustomtab'] = array(
		'name' => 'Siparişlerim',
		'icon' => 'um-faicon-comments',
	);

	return $tabs;
		
}
/* Then we just have to add content to that tab using this action */

add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default');
function um_profile_content_mycustomtab_default( $args ) {
	require ("my-orders.php");
}
//----------------------------------------------

add_filter('um_profile_tabs', 'add_custom_profile_tabi', 1000 );
function add_custom_profile_tabi( $tabs ) {

	$tabs['mycustomtab2'] = array(
		'name' => 'My custom tab2',
		'icon' => 'um-faicon-comments',
	);

	return $tabs;
		
}
add_action('um_profile_content_mycustomtab2_default', 'um_profile_content_mycustomtab2_default');
function um_profile_content_mycustomtab2_default( $args ) {
echo "hello";}

Hi,
In the tab I want to write "Members" and link it to the members page. Can anyone please assist?

Carlvic commented Jul 16, 2017

Hello!

How can I add upload field on my custom tab?

I use this code but it's all blank

`
"/* 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">
	
	   <div class="custom-profile-update">
           <?php echo do_shortcode('[ultimatemember form_id=692]'); ?>
	
</div>		
	
<?php
	
$output .= ob_get_contents();
ob_end_clean();
return $output;

}
`

Great examples above but all I would like to do is change the "Posts" tab title to the name of my custom post type "Ratings". I've already got the code to bring in the Ratings. I've searched everywhere and haven't seen any examples of how to change the titles of the existing tabs.
Thanks in advance.

MvdO commented Aug 3, 2017

I also need a code example to just change the existing tab names/slugs (Posts,Comments), anyone?

// i am trying to create a custom tab as below

/* First we need to extend main profile tabs */

add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 );
function add_custom_profile_tab( $tabs ) {

$tabs['createevent'] = array(
	'name' => 'Create Event',
	'icon' => 'um-faicon-comments',
);
	
return $tabs;

}

/* Then we just have to add content to that tab using this action */

add_action('um_profile_content_createevent_default', 'um_profile_content_createevent_default');
function um_profile_content_createevent_default( $args ) {
echo do_shortcode( '[custom_short_code id="274"]' );

}

Problem: Tab disappeared as i replaced mycustomtab to createevent ??

Garconis commented Dec 1, 2017

Does this still work in version 2.0? I can't get this to work.

Hi Guys!

Thanks to your comments I have been playing around with the code also but with limited success. I am no developer but at least I was able to add more tabs using the function php file. Now my problem is the following:
I would like my new created tab to redirect to a specific URL.
I have successfully called the tab "Submit Property" but when I click on the tab as a logged in user nothing happens. Can someone supply me with the code in order to redirect the tab to a URL placed outside the plugin please.

I believe i need to make some changes in the last bit of code and add smth like <a href=“URL"> but I am not 100% sure and would appreciate help! Thank you!!

I used this code from "eminsafa" example


add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 );
function add_custom_profile_tab( $tabs ) {

$tabs['mycustomtab'] = array(
	'name' => 'Submit Property',
	'icon' => 'um-faicon-comments',
);

return $tabs;

}
/* Then we just have to add content to that tab using this action */

add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default');
function um_profile_content_mycustomtab_default( $args ) {
require ("my-orders.php");
}

A BIG THANK YOU
Sabrina

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment