Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/20bda2c0575eb9579bdc to your computer and use it in GitHub Desktop.
Save champsupertramp/20bda2c0575eb9579bdc to your computer and use it in GitHub Desktop.
Ultimate Member - Add custom tab & section
<?php
/**
* Add profile content for 'Pages' tab's section
* @param Array $args
* @hook Action 'um_profile_content_pages'
*/
function um_custom_add_profile_content_pages( $args ){
echo "Hello World";
}
add_action('um_profile_content_pages','um_custom_add_profile_content_pages',10,1);
?>
@Jr2323
Copy link

Jr2323 commented Nov 18, 2016

Hi and thank you for wonderful support system here!

I am running Ultimate Member WP plugin and am trying to create a custom tab called Faves for my user profile pages where only certain user roles I determine can view
it:


<?php
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {

	$user_id = um_get_requested_user();
	// Show to profile owners only
	if ( is_user_logged_in() && get_current_user_id() == $user_id ) {
		$tabs['faves'] = array(
			'name' => 'Faves',
			'icon' => 'fa fa-star',
			'custom' => true
		);
	}

	// Show to other profiles 
	if ( is_user_logged_in() && get_current_user_id() != $user_id ) {
		$tabs['faves'] = array(
			'name' => 'Faves',
			'icon' => 'fa fa-star',
			'custom' => true
		);
	}

	// Show to everyone
	$tabs['faves'] = array(
			'name' => 'Faves',
			'icon' => 'fa fa-star',
			'custom' => true
	);

	// Hide from specific roles
	$hide_from_roles = array( 'member','admin' );

	if ( is_user_logged_in() && ! in_array( um_user('role') , $hide_from_roles )  ) {
		$tabs['faves'] = array(
			'name' => 'Faves',
			'icon' => 'fa fa-star',
			'custom' => true
		);
	}
	
	return $tabs;
}

?>

I paste this code in the theme's functions.php, and the Faves tab shows up OK, but for everybody. Even when I enter user role "member"
and changing the others to 'custom' => false, nothing happens. It seems the role conditions part of the code is not good.

Please help me determine why.

Thanks very much in advance!

@elias1435
Copy link

hello @champsupertramp ,
would you help me to display all the custom posts in a custom profile tab? I am trying to find but I fail...

Thanks in advance

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