Jump to content

how pages that logged user has created in admin panel


ziu
 Share

Recommended Posts

i used that module but its not what i was looking for, i have below mentioned pages.

Properties (parent template)
---Property 1   created by admin
---Property 2   created by user1
---Property 3   created by user1
---Property 4   created by admin
---Property 5   created by user1

But i when 'User1' login to his account-- i want to show only those pages which he has created. like below

Properties (parent template)
---Property 2   created by user1
---Property 3   created by user1
---Property 5   created by user1

 

 

Thank you, any help will be appreciated.

 

Link to comment
Share on other sites

It sounds like easiest approach would be to change it to look like this:

Properties
---User 1
-------Property 1
-------Property 3
---User 2
-------Property 2
-------Property 4

I understand that might be an issue for the url structure on your site. There are ways around this though.

The other option is https://processwire.com/talk/topic/1176-hiding-uneditable-pages-from-users/?do=findComment&comment=84916 - read that post and the post that it links to and the rest of both threads. There are ways to do this that should work fine and in your scenario I don't think the mentioned problems will be an issue. Let us know if you need help with any of the linked scripts.

  • Like 2
Link to comment
Share on other sites

Thank you adrian, you are so quick, thanks alot, i guess the links you shared can possibly solve my problem and i am  also thinking about the way you presented the paging approach. thank you. will update you  soon. 

  • Like 1
Link to comment
Share on other sites

2 hours ago, ziu said:

@adrian hi , can you show me the right way to use 'createdUser' api , i  want to match this with the logged in user so that i can display those pages only which has been created by the same user who is loggedin. 

Well, it's pretty much just like this. If the createdUser property for the given page matches the current user, it will return true, otherwise false. If that doesn't make sense, maybe post some code so we can debug for you.

5a0db11184acd_ScreenShot2017-11-16at7_38_39AM.png.0c07f1c773e2db0572589c269795f202.png

  • Like 2
Link to comment
Share on other sites

i have created a custom admin  page which shows pages of a template only... below is the code, but i want to show only those pages that are created by the login user. as i already tried other solutions you mentioned above, but i am totally confused that, how can display those pages.

 


<?php


$u=$user->id;
$this->modules->get('JqueryMagnific');

//render PageListtree with setting the parent page
$formImages = $this->modules->get('InputfieldForm'); // prep the form
$wrapperImages = new InputfieldWrapper; // a wrapper
$wrapperImages->attr('value', '<h2>Artist Registration Page</h2>');

$i = $this->modules->get('ProcessPageList'); // here i want to display only those subpages which matches to the user logged in
$i->set('id', 5845); // setting the parent page

$pageTreeImages = new InputfieldMarkup; // the placeholder
$pageTreeImages->value = $i->execute(); // fill the InputfieldMarkup form field...

$wrapperImages->add($pageTreeImages); // put inside the wrapper...
$formImages->append($wrapperImages); // append the wrapper

 


?>

Link to comment
Share on other sites

To hide pages from ProcessPageList for non-superusers (doesn't apply for superusers) you can hook Page::listable().

$page->listable()
bool Returns true if the page is listable by the current user, false if not. 
Can also be used as property: $page->listable

 

So to hide pages that the user cannot edit you can add this to /site/ready.php:

$wire->addHookAfter('Page::listable', function(HookEvent $event) {
    $page = $event->object;
    if(!$page->editable) $event->return = false;
});

 

  • Like 1
Link to comment
Share on other sites

hi @adrian that worked , now user can edit only those pages which he has created, but user still can see all other pages, can't we do anything to hide other pages that he has not created in list, i already tried to use higepagesuser module, but thats not working. 

Help

Link to comment
Share on other sites

@adrianyour hideotherpages and hideuneditable modules works like charm, but i used createdUser->id with User->id  to match and show only those pages which a user has created. 

Many thanks to adrian, i really appreciated the way he reponds.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...