Flashmaster82
Members-
Posts
182 -
Joined
-
Last visited
Everything posted by Flashmaster82
-
If i use this if($page->template != "auction-bid, auction_bid_date>=$parentdateminusstart, auction_bid_date<=$parentdateminusend") return; It will not work, but if i remove the date variables then it will work. So something is wrong with it.. hmm if($page->template != "auction-bid") return; Should i place the variables elsewhere?
-
The parent field (auction_end_date) is set. First i add auction-page, then users will add bid (auction-bid).
-
Well the code is not working correct. I don´t now how to fix it. I want it to look for if the current time is less than 3min from the end date.
-
I wan´t to change the parent page date when a child is added 1sek - 3 min left of the date/time. $wire->addHookAfter('Pages::added', function(HookEvent $event) { $page = $event->arguments(0); $pageparentdate = $page->parent->auction_end_date; $parentdateminusstart = date( 'Y-m-d H:i:s', strtotime($pageparentdate . ' - ' . "3" . ' minutes')); $parentdateminusend = date( 'Y-m-d H:i:s', strtotime($pageparentdate)); if($page->template != 'auction-bid, auction_bid_date>=$parentdatestart, auction_bid_date<=$parentdateend') return; $parent = $page->parent; $parentdate = $parent->auction_end_date; $parentdateadded = date( 'Y-m-d H:i:s', strtotime($parentdate . ' + ' . "3" . ' minutes')); $parent->setAndSave('auction_end_date', $parentdateadded); }); Parent template= auction-page Child template=auction-bid End date field = auction_end_date The code is working but i don´t know how to do with the date. 3 min > enddate.
-
@gebeer That worked!! Thanks alot!!!
-
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..
-
@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(); ?>
-
$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()
-
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; });
-
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.
-
$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!!
-
@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);
-
Ok thanks i will have a look. But the problem is that the edit button don´t show up..
-
@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.
-
@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
-
Has anyone any clue how to enable the (Edit) button for non Superusers? I really need to solve this.. please help!!
-
How to output log from module in front end
Flashmaster82 replied to Flashmaster82's topic in General Support
Thanks for the explanation, i will try to work something out. -
How to output log from module in front end
Flashmaster82 replied to Flashmaster82's topic in General Support
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 -
How to output log from module in front end
Flashmaster82 replied to Flashmaster82's topic in General Support
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>"; } -
How to output log from module in front end
Flashmaster82 replied to Flashmaster82's topic in General Support
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 -
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..
-
Hook to select first option in page reference fieldtype
Flashmaster82 replied to Flashmaster82's topic in General Support
Thanks for the reply, i will check it out. -
Hook to select first option in page reference fieldtype
Flashmaster82 replied to Flashmaster82's topic in General Support
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. -
Hook to select first option in page reference fieldtype
Flashmaster82 replied to Flashmaster82's topic in General Support
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"