Keyword

[SOLVED] K2 Author Profile Access Level

  • Gary
  • Gary's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 9 months ago #145463 by Gary
K2 Author Profile Access Level was created by Gary
Is there a way to restrict viewing the articles Author to only registered users and above? On my site, public has access to view articles but I only want registered users to be able to view the authors name and if they click the name, to view the profile and therefore the contact details.
I have searched the forums and the net for something about this and come up empty.

Anyone know how to do this?

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
8 years 9 months ago #145599 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic K2 Author Profile Access Level
There are two areas author information is displayed on an item
1. Written By
2. Authors block at the bottom

To hide the written by to guest, you can do this by changing this line in item.php (Do a template override first)
Find
<?php if($this->item->params->get('itemAuthor')): ?>
		<!-- Item Author -->
Add
<?php if($this->item->params->get('itemAuthor') && !$this->user->guest): ?>
		<!-- Item Author -->

For the authors block
Find
<?php if($this->item->params->get('itemAuthorBlock') && empty($this->item->created_by_alias)): ?>
  <!-- Author Block -->

Add
<?php if($this->item->params->get('itemAuthorBlock') && empty($this->item->created_by_alias) && !$this->user->guest): ?>
  <!-- Author Block -->

K2 Rocks \m/

Please Log in or Create an account to join the conversation.

  • Gary
  • Gary's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 9 months ago #145822 by Gary
Replied by Gary on topic K2 Author Profile Access Level
This does not work. Adding these lines delivers a blank page when displaying an article to the public view. Also, when a registered user logs in, who should be able to see author details, they also get a blank page.

New issue- Clicking on the Author, either in the "written by" or in the "authors block" does not take the user to the authors information page. It only display other articles by the author. It needs to show the authors details, at least when clicking the authors block.

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
8 years 9 months ago #145823 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic K2 Author Profile Access Level
what is the error you get ? try tun on the error reporting to maximum in the joomla global configuration

K2 Rocks \m/

Please Log in or Create an account to join the conversation.

  • Gary
  • Gary's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 9 months ago #145830 by Gary
Replied by Gary on topic K2 Author Profile Access Level
The error is:

"Notice: Use of undefined constant JPATH_COMPONENT_ADMINISTRATOR - assumed 'JPATH_COMPONENT_ADMINISTRATOR' in /home/homework/public_html/plugins/k2/incptvk2multipleextrafieldgroups/models/item.php on line 15"

This appears to be in a plugin I am using for extra fields that K2 does not provide. Line 15 in that plugin is:

"JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');"

In searching for this error, less the plugin reference, I find that there are a lot of posts.
Since the error is only a PHP Notice, why would it cause a blank screen?
From what I can determine, the line itself is common in my Joomla operations and should not cause the problem. If I leave your code lines out, the page displays properly

In fact, the NOTICE appears with error reporting on and your code lines NOT present. The pages still display normally.
Adding your code does NOT create the error message, but DOES create the blank screen.

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
8 years 9 months ago #145831 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic K2 Author Profile Access Level
I just tried in a fresh install of Joomla 3.4.3 and K2 2.6.9 and the code worked. Can you set the error reporting to development and see if there is any syntax error ?

K2 Rocks \m/

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
8 years 9 months ago #145832 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic K2 Author Profile Access Level
my line of code looks like this in item.php
.....
	<?php if($this->item->params->get('itemAuthor') && !$this->user->guest): ?>
		<!-- Item Author -->
		<span class="itemAuthor">
			<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>&nbsp;
			<?php if(empty($this->item->created_by_alias)): ?>
			<a rel="author" href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
			<?php else: ?>
			<?php echo $this->item->author->name; ?>
			<?php endif; ?>
		</span>
		<?php endif; ?>
....

K2 Rocks \m/

Please Log in or Create an account to join the conversation.

  • Gary
  • Gary's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 9 months ago #145838 by Gary
Replied by Gary on topic K2 Author Profile Access Level
Yes - that is exactly how I have it.
I too have J3.4.3 and K2 2.6.9
The K2 templates are in an override. and that is where the changes are being made.
Development errors settings provide nothing new. In fact that setting, without these changes, creates problems accessing the K2 articles, also giving a blank screen with NO error. Setting it to Maximum and all pages display (showing the typical STRICT STANDARDS messages or the NOTICE as discussed before.
I think I discovered the issue-- originally you said to ADD:
"<?php if($this->item->params->get('itemAuthor') && !$this->user->guest): ?>"
so that is what I did.
However, if I REPLACE the original line:
"<?php if($this->item->params->get('itemAuthor')): ?>" with this then this works.

p.s. I do not seem to be able to comment out the original lines. neither <!--xxxxx--> nor /** xxxx **/ seem to work. either one causes the blank screen if the original line is left in. I need to delete it for this to work.

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
8 years 9 months ago #145839 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic K2 Author Profile Access Level
can you add this in item.php and see if it works
<?php
	  	$user = JFactory::getUser();
		if ($user->guest) { echo 'You are not logged in'; } else { echo 'You are logged in'; }
	  ?>

K2 Rocks \m/

Please Log in or Create an account to join the conversation.

  • Gary
  • Gary's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 9 months ago #145842 by Gary
Replied by Gary on topic K2 Author Profile Access Level
Yes that works. I probably will not use it. I will inform users in some other way that they must be registered to see item details like this.
Good idea tho!

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum