OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



How to get user role along with name in login Box

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

How to get user role along with name in login Box

Postby rameshnispaara » Fri Apr 23, 2010 3:25 am

Hi,

After login, I want ti display the like this 'You are logged in as sanjana: author'.
but I tried this code which in index.tpl of user in user block.tpl. The code is below

{assign var="journalId" value=$journal->getJournalId()}
{section name=role loop=$userRoles[$journalId]}
{if $userRoles[$journalId][role]->getRolePath() != 'reader'}
<li>&#187; <a href="{url journal=$journal->getPath() page=$userRoles[$journalId][role]->getRolePath()}">{translate key=$userRoles[$journalId][role]->getRoleName()}</a></li>
{/if}
{/section}

But I git below Error.

Fatal error: Call to a member function getJournalId() on a non-object.



Any one would help me.
Thanks in advance.
rameshnispaara
 
Posts: 1
Joined: Fri Apr 23, 2010 3:14 am

Re: How to get user role along with name in login Box

Postby mcrider » Fri Apr 30, 2010 10:45 am

Hi rameshnispaara,

It looks like journal object is not available to the template you are using--you'll have to assign it by putting something like
Code: Select all
$journal =& Request::getJournal();
$templateMgr->assign_by_ref('journal', $journal);

In the getContents() function of the UserBlockPlugin.inc.php file.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 0 guests

cron