Extension:SocialProfile/Hooks/UserProfileGetProfileHeaderLinks

UserProfileGetProfileHeaderLinks
Available from version 1.31 (Gerrit change 327175)
Allow extensions adding links to the profile header or maybe even removing them
Define function:
public static function onUserProfileGetProfileHeaderLinks( UserProfilePage $upp, &$profileLinks ) { ... }
Attach hook:
$wgHooks['UserProfileGetProfileHeaderLinks'][] = 'MyExtensionHooks::onUserProfileGetProfileHeaderLinks';
Called from:File(s): SocialProfile / UserProfile/includes/UserProfilePage.php

For more information about attaching hooks, see Manual:Hooks .
For examples of other extensions using this hook, see Category:UserProfileGetProfileHeaderLinks extensions.

Example

edit
/**
 * Adds a "Create blog post" link to the social user profile pages
 *
 * @param UserProfilePage $upp
 * @param array &$profileLinks Array of existing profile links
 */
public static function onUserProfileGetProfileHeaderLinks( $upp, &$profileLinks ) {
	// $upp->getContext()->getUser() refers to the currently _viewing_ user, not
	// to the user whose profile is being viewed
	// Show this link only to registered users who are *not* viewing their own profile
	$ctx = $upp->getContext();
	$user = $ctx->getUser();
	if ( $upp->isOwner() &&
		MediaWiki\MediaWikiServices::getInstance()->getPermissionManager()->userHasRight( $user, 'createblogpost' ) )
	{
		$createBlogPost = SpecialPage::getTitleFor( 'CreateBlogPost' );
		$profileLinks['createBlogPost'] =
			'<a href="' . htmlspecialchars( $createBlogPost->getFullURL(), ENT_QUOTES ) . '" rel="nofollow">' .
				$ctx->msg( 'createblogpost' )->escaped() .
			'</a>';
	}
}