Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Flashmaster82

  1. @gebeer That worked!! Thanks alot!!!
  2. Im trying to redirect a logged in user back to his own user page if he tries to access another member page, but i can´t get it to work. It will redirect back to the correct url but then i get browser error? "The page redirects incorrectly, Firefox has detected that the server is redirecting the request for this location in a way that prevents completion." <?php $userloggedinname = $user->name; $pagename = $page->name; { $session->redirect( "{$pages->get(1)->httpUrl}medlemmar/" . $userloggedinname ); } ?> also i tried this but same result $userloggedinname = $user->name; $pagename = $page->name; if (!$userloggedinname === $pagename) { $session->redirect("{$pages->get('/')->url}medlemmar/{$userloggedinname}"); } I have created another user template similar to this post https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users So my users is now under Home/Members/MemberX I´m on localhost. Also i if a user is logged in, the user can edit other users aswell 😞 so my goal is also to hide/restrict users to edit or access the processwire front end user edit page. I am building a separate edit on the front end user custom page that also is the memberX page, Home/Members/MemberX. Any suggestions? Please help..
  3. @gebeer Thanks for the detailed reply.. very appreciated. 🙂 This is my current code. The dropdown with all its option is now visible but when i submit the form the value is not selected. (County) is the option field.. any clues? <?php $fu = $modules->get( 'FrontendUser' ); $redirectDestination = htmlentities( $_SERVER[ 'REQUEST_URI' ] ); $firstname = $modules->get( 'InputfieldText' ); $firstname->label = $this->_( $fields->firstname->$label ); $firstname->attr( 'id+name', 'firstname' ); $firstname->required = 0; $firstname->fhSanitizer = 'text'; $firstname->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->firstname = $mySanitizedCustomInput; }); $location = $modules->get( 'InputfieldText' ); $location->label = $this->_( $fields->location->$label ); $location->attr( 'id+name', 'location' ); $location->required = 0; $location->fhSanitizer = 'text'; $location->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->location = $mySanitizedCustomInput; }); /* Option field */ $form = $modules->get('InputfieldForm'); $county = $modules->get('InputfieldSelect'); $county->attr('id+name', 'county'); $county->label = $this->_($fields->county->label); $county->required = 1; $county->attr('required', 'required'); $optionsArray = $pages->findRaw('template=county', 'title'); $county->setOptions($optionsArray); $form->add($county); $form->render(); $county->fhSanitizer = 'text'; $county->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->county = $mySanitizedCustomInput; }); $fu->addHookBefore('save', function($event) { $form = wire('fu')->form; $user = wire('fu')->userObj; $user->addRole('member'); $user->parent = "/medlemmar"; $user->template = "member-page"; }); $fu->register( array( 'username', 'email', 'password', $firstname, $county) ); $redirectDestination = $pages->get( '/logga-in' )->url; $fu->process( $redirectDestination ); echo $fu->render(); ?>
  4. $optionsArray = $pages->findRaw('template=location', 'title'); $location->setOptions($optionsArray); $location = $modules->get( 'InputfieldText' ); $location->label = $this->_( $fields->location->$label ); $location->attr( 'id+name', 'location' ); $location->required = 1; $location->fhSanitizer = 'text'; $location->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->location = $mySanitizedCustomInput; }); Thanks for the reply.. I´m a beginner with php so don´t know how to insert this.. 😞 Getting Fatal Error: Uncaught Error: Call to a member function setOptions()
  5. How to you add a page reference dropdown to the form? I´ve got this $county = $modules->get( 'InputfieldSelect' ); $county->label = $this->_( $fields->county->$label ); $county->attr( 'id+name', 'county' ); $county->required = 1; $county->fhSanitizer = 'text'; $county->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->county = $mySanitizedCustomInput; });
  6. Im building a site where members can hopefullly sign up, login, and have a front end user page that that they can edit and also post new for example entries/pages to an auction for example. I have created an alternative user page based on this post. https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users So my new template is "member" with the parent "members". This is where all my new user will end up but they will also have a parent under the regular users page. I have created a form from "frontedituser" module. So now the users can signup and login from localhost/userarea/logga-in. But the problem is that once the user is logged in they also can access other users pages with the parent home/medlemmar/.. I want only the logged in user to be able to visit the users profile page.. home/medlemmar/testuser1 for example. I have also tried to get you an overview of everything in the attached image. If you have any clues or have some other/better solutions please let me know.. /thanks.
  7. $wire->addHookAfter('Pages::added(template=booking)', function(HookEvent $event) { $page = $event->arguments(0); $selectable_pages = $page->getInputfield('booking_group')->getSelectablePages($page); $current_group = $selectable_pages->find("template=booking_price, parent.booking_current_group=1"); $first = $current_group->eq(0); $second = $current_group->eq(1); if ($page->booking_numberofpeople->id == 1 ) { $page->setAndSave('booking_group', $first); } else if ($page->booking_numberofpeople->id !== 1 ) { $page->setAndSave('booking_group', $second); } }); I have this code in ready.php It works when i change to (Pages::save) but when (Pages::added) it doesn´t work? It sets the value to $second regardless.. Any clues? booking_group = page reference field booking_numberofpeople = select option field the options in booking_numberofpeople is 1=1 2=2 3=3 4=4 5=5 Also i have set the required value to 1. The pages are created from the module (Simple Contact Form). Please help!!
  8. I can´t even install the module.. ?? Any clues? Parse Error: syntax error, unexpected 'Validator' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) (line 20 of E:\Wamp\www\Website\site\modules\FrontendForms\FrontendForms.module)
  9. @zoeck Yes but the module only let you restrict branches not give rights to edit pages. The problem is that the Edit button not showing up.. Maybe its because its a user-page and not a regular one. I don´t know how to solve this.. I have this code in my config.php $config->userTemplateIDs = array(3, 53); $config->usersPageIDs = array(29, 1047);
  10. Ok thanks i will have a look. But the problem is that the edit button don´t show up..
  11. @zoeck My main goal is to have users, register > log in to their account > edit their own profile page > add children. so based on this post https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users i clone the user template and renamed it member. So now i can create a new user with another template and also change parent. And also the user now have a page under home/members/. The subpage under the "newuser" > newsubpage shows the edit button but not newuser.
  12. @zoeck thanks for the fast reply. I have really tried everything.. permissions etc.. can´t get it to work.. also i have tried to modify the module file but no luck. <?=$page->feel();?> This is how i outfut the button from the module. Have you also changed the guest role? Do you have a screenshot with your settings? The page is an user page renamed "member" with template name "member" that i have cloned and the parent is Home/Members/ and also listed in the users page. https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users
  13. Has anyone any clue how to enable the (Edit) button for non Superusers? I really need to solve this.. please help!!
  14. Thanks for the explanation, i will try to work something out.
  15. Yes i saw that but as a said before i´m a beginner at PHP.. Can you give me some hint/example.. i´m struggling here ? /Thanks
  16. But how do i get specific log? Lets say you are on a page that outputting the form message (front end). I only want that specific message attached to the page. Same date for example. $myLogs = $log->getLines("simplecontactform-log"); foreach ($myLogs as $logs) { echo $logs . "<br><br><br>"; }
  17. Well its hard to understand that page for a beginner when there is no real examples. This is the closest i got. $scf = $modules->get('SimpleContactForm'); $wire = $log->getLogs($scf); foreach($wire as $hejda){ echo $hejda . "<br>"; } And it outputs Array Array Array Array Array Array
  18. I have the "simple contact form" module. And it creates a log in Setup->logs (simplecontactform-log) for every sent email from the form. I want to output the logs in the front end? I also displaying the every email in the front end so i also want the specific log be attached to it. Is that possible? Please help..
  19. Thanks for the explanation. I wanted to use the eq thing but i don´t know how? Im not that good at PHP but im learning. Did 2 different approaches. $status3 = $pages->get('/bokningsstatus/steg3/'); if ($bookingstatus->booking_status === $status3) { require ('assets/bookingstatus/bookingstatus_step3.inc.php'); } if ($bookingstatus->booking_status->id == 1738) { require ('assets/bookingstatus/bookingstatus_step1.inc.php'); } But i wanted to do an if statement if the status in the dropdown is at the first, second, third etc.. with the eq. Then include the inc file. Because if you change the references i wont work.
  20. I have another page that im using a page reference on (booking_status), i tried with the same logic "eq(1)" but it didnt worked? Is eq only for hooks? if ($bookingstatus->booking_status->eq(1)) { require ('assets/bookingstatus/bookingstatus_step2.inc.php'); } I get "Exception: Method Page::eq does not exist or is not callable in this context"
  21. It worked like a charm. Thank you so much!!! I tried to specify the parent but i didnt worked? $wire->addHookAfter('Pages::added', function(HookEvent $event) { $page = $event->arguments(0); if($page->template != 'booking, parent=/nya-bokningar/') return; $selectable_pages = $page->getInputfield('booking_searchactivator_option')->getSelectablePages($page); $first_selectable_page = $selectable_pages->eq(0); $page->setAndSave('booking_searchactivator_option', $first_selectable_page); });
  22. I want to select the first option in a page reference fieldtype when adding a new page (admin). Dont want to target the option id because the value may change. Field = booking_searchactivator_option Template = booking Page reference template = searchactivator My current code is only targeting the page id and not the value. So now it becomes id=1. Also i want to be able to change the value to the second value, third value / position in the dropdown. $wire->addHookAfter('Pages::added', function(HookEvent $event) { $page = $event->arguments(0); if (!$page->matches('template=booking')) return; $aktivator = 1; $page->setAndSave('booking_searchactivator_option', $aktivator); }); i also have another hook that removes already selected page references. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { $page = $event->arguments(0); if($event->object->hasField == 'booking_searchactivator_option') { $pages = $event->wire()->pages; $already_selected_on_another_page = $pages->find("template=searchactivator, booking_searchactivator_option.owner.template=booking, booking_searchactivator_option.owner.id!=$page->id"); $event->return = $event->pages->find("template=searchactivator, sort=sort, id!=$already_selected_on_another_page"); } }); Please help!!
  • Create New...