krisj Posted June 28, 2016 Share Posted June 28, 2016 2 hours ago, Beluga said: Note that I don't use that solution anymore, but pwFoo's simpler solution. probably makes sense in your case. I still need the user welcome email functionality provided by the EmailNewUser module. e.g. it uses the same template for api and manually created users as well as "resend" functionality which is handy. and only takes 1 short line of code to make it work with the FrontendUser. Link to comment Share on other sites More sharing options...
krisj Posted June 28, 2016 Share Posted June 28, 2016 @pwFoo just posted an issue re token verification not functioning seems like the suggested addition to hide the token field before it needs to be visible is after breaking the validation. for now (assuming you are using the latest version) you need to comment line 129 and uncomment 128 (reverting back 1 commit). I should have tested more extensively before suggesting the change take care... Link to comment Share on other sites More sharing options...
pwFoo Posted June 28, 2016 Author Share Posted June 28, 2016 Hi @krisj so I should reverting the it to my original code? Maybe I should freeze changes until I have the time to test it before commit... Link to comment Share on other sites More sharing options...
pwFoo Posted June 30, 2016 Author Share Posted June 30, 2016 Updated (reverted change which causes the problems) to 0.9.2 I hope it works again, because I haven't time or envirionment to test it... If it works fine I do a change freeze here until I back with update, tests, supports ... Link to comment Share on other sites More sharing options...
hansv Posted August 14, 2016 Share Posted August 14, 2016 I have a redirection problem! in chrome: to many redirections in firefox: page is not redirected in a proper way My code with or without the if else, same problem the inlog form is shown correctly and when I go to the backend I'm logged in <?php if ($user->isGuest()) { // load module $fu = $modules->get('FrontendUser'); // prepare login form (default parameters) $fu->login(); // Additional LoginPersist and ProcessForgotPassword module integration (built-in) $fu->login(array('username', 'password', 'forgot')); // process login / form submit $fu->process($pages->get('/ledenzone/')->url); // output form $body .= $fu->render(); } else { // do logout } Any suggestions, many thx Link to comment Share on other sites More sharing options...
pwFoo Posted August 14, 2016 Author Share Posted August 14, 2016 Hi, you should execute the login() method one time. In your code it's called twice. If the login was successful you will redirected by the process() method to the destination. It looks like your $fu->process(...) call is executed every time. Could you add some debugging output and break the execution of the template file with the php exit? So you should see your debugging information and debug your code. 1 Link to comment Share on other sites More sharing options...
hansv Posted August 14, 2016 Share Posted August 14, 2016 @pwfoo, thx for the debug-suggestion I deleted login() After debugging wit php exit: location of the problem in the FrondendUser.module switch case: $result = 1 if result === true before $this: $result = 1 $this->session->redirect($redirect, false); // User sucessfully registered causes the loop that terns in a 302-error Any suggestions for a solution? /** * Process user register with validated form input * @param string $redirect Redirect destination url */ public function process($redirect) { if ($this->form->fhProcessForm()) { switch ($this->action) { case 'Login': $result = $this->auth($this->userObj); break; case 'Register': $result = $this->save($this->userObj); break; } if ($result === true) { $this->session->redirect($redirect, false); // User sucessfully registered } else { $this->form->fhSubmitBtn->error($result); // Save user failed? echo 'save user failed: ' . $this; // } } return $this; } Link to comment Share on other sites More sharing options...
hansv Posted August 14, 2016 Share Posted August 14, 2016 I exported my profile into a new PW installation and now I get a fatal error: Fatal error: Call to a member function login() on null in D:\xampp\htdocs\pwf6_str08\site\templates\account-login.php on line 8 Code line 8: $fu->login(array('username','password','forgot')); Link to comment Share on other sites More sharing options...
pwFoo Posted August 15, 2016 Author Share Posted August 15, 2016 16 hours ago, hansv said: I exported my profile into a new PW installation and now I get a fatal error: Fatal error: Call to a member function login() on null in D:\xampp\htdocs\pwf6_str08\site\templates\account-login.php on line 8 Code line 8: $fu->login(array('username','password','forgot')); That sounds like a problem with your installation or missing module. $result would be (exactly) true if a new user is registered. /** * Save the temp User object * @param User $user Temp User object to save * @return boolean Sucessful (true) saved or not (false) */ protected function ___save($user) { if (empty($user->name) || empty($user->email) || $user->pass->hash == '') { return $this->_('Register process unexpected failed!'); } if ($user->save()) { return true; } return $this->_('User registration failed!'); } And the save() method will prevent duplicates. I don't think the loop is generated by the module. Should be template code like the prevent redirection loops example. Do you redirect to the current page or is there a htaccess rewrite? Redirect to login page? ... Anyone else have such problems with the module? Additional examples could be helping. 1 Link to comment Share on other sites More sharing options...
hansv Posted August 15, 2016 Share Posted August 15, 2016 I re-installed the module, now only the 302 redirect loop. My template-code <?php // load module $fu = $modules->get('FrontendUser'); // Additional LoginPersist and ProcessForgotPassword module integration (built-in) $fu->login(array('username','password','forgot')); // process login / form submit $fu->process($pages->get('/ledenzone/')->url); // output form $body .= $fu->render(); .htaccess the original PW 3.0, now changes maded When I login as a non-existing user, I get the 'login failed' message When I login as admin or as existing user I get the redirection loop I'm just logging in, it' not about a registration of a new user Link to comment Share on other sites More sharing options...
hansv Posted August 15, 2016 Share Posted August 15, 2016 @pwFoo Problem solved. No blames to the FrontEndUser-module, all shame is for me!!! In my _main.php there was also code to log in. It was ment for a button to login. Conclusion: there was interference between login-code in the _main.php file and the login-code in the template file. Sorry for wasting your time, the FrontEndUser-module is excellent. 1 Link to comment Share on other sites More sharing options...
pwFoo Posted August 15, 2016 Author Share Posted August 15, 2016 @hansv Thanks for feedback about the reason! I'm happy you solved the problem 6 minutes ago, hansv said: the FrontEndUser-module is excellent. It just use the power of Processwire API and hooks 2 Link to comment Share on other sites More sharing options...
modifiedcontent Posted September 5, 2016 Share Posted September 5, 2016 FrontendUser and FormHelper are the first modules I have installed in Processwire, so I am still very confused about the basics. When I put this in a template file: $fu = $modules->get('FrontendUser'); echo $fu->login(null, $redirectDestination); The output in the site is just the text 'FrontendUser', no login form as I had hoped. What am I missing? Probably something very dumb and obvious. Link to comment Share on other sites More sharing options...
pwFoo Posted September 6, 2016 Author Share Posted September 6, 2016 Could be happen if $redirectDestination is empty. if (empty($redirect)) { return $this; } https://bitbucket.org/pwFoo/frontenduser/src/308afb5ae6517c210a0712fe0124f6892e2fd48f/FrontendUser/FrontendUser.module?at=master&fileviewer=file-view-default#FrontendUser.module-67 Link to comment Share on other sites More sharing options...
modifiedcontent Posted September 6, 2016 Share Posted September 6, 2016 Thanks pwFoo. Following the documentation I assumed there was a default $redirectDestination somewhere, like "SELF" - would that be '$_SERVER['PHP_SELF']' or '$_SERVER['REQUEST_URI']' or is there a PW specific way to do that? What does 'return $this' do in your empty($redirect) test? Link to comment Share on other sites More sharing options...
pwFoo Posted September 7, 2016 Author Share Posted September 7, 2016 No, there is no default like "SELF". Be careful "SELF" could cause a redirection loop:https://bitbucket.org/pwFoo/frontenduser/wiki/Documentation#markdown-header-prevent-redirection-loops 21 hours ago, modifiedcontent said: What does 'return $this' do in your empty($redirect) test? return the current instance / object. echo out the object will print the class name I think. Link to comment Share on other sites More sharing options...
modifiedcontent Posted September 9, 2016 Share Posted September 9, 2016 Thanks pwFoo. Is there a complete basic working code example anywhere? This is what I have so far: <?php $fu = $modules->get('FrontendUser'); $redirectDestination = htmlentities($_SERVER['REQUEST_URI']); if ($user->isGuest()) { $fu->register(); $fu->process($redirectDestination); echo $fu->render(); echo 'or log in here if you already have an account'; echo $fu->login(null, $redirectDestination); // with default fields } if($user->isLoggedin()) { if (isset($_GET['logout'])) $fu->logout($redirectDestination); echo "<a href='?logout'>Logout</a>"; } ?> Login/logout works fine. Registration adds a new user, but the user would never know; I need to figure out how to send him/her an email confirmation, with an activation link maybe (?), log them in automatically, ..., what else? I also don't want my registration form to ask for a "username"; only real name - firstname, lastname - and email address and then later maybe addition info. I'll probably end up generating a username from the real name in the background, as I've always done in Wordpress. All these points have probably been discussed somewhere in this long thread, but is there any place where it is all put together into one working example? The documentation gives the basic functions/usage (?) but not how to put it together, leaving out essential points that may be obvious for regular Processwire users, but not if this is the first PW module you try to implement after years in WP world. The code snippets/examples then skip ahead to sanitizing and custom fields. I can't find anywhere how to add an activation link email process. Email activation is mentioned here, but mixed in with a lot of other issues. Where should I start? Link to comment Share on other sites More sharing options...
flydev Posted September 15, 2016 Share Posted September 15, 2016 On 09/09/2016 at 3:04 PM, modifiedcontent said: Email activation is mentioned here, but mixed in with a lot of other issues. Where should I start? If I understand correctly, you want the email activation plugin. In the backend, install the module FrontendUserRegisterEmailValidation then you call the module like that (but read the rest of the post and test it) : $fu = $modules->get('FrontendUser'); // add emailValidation to the form $fu->register(array('username', 'email', 'emailValidation', 'password')); $fu->process($pages->get('/login/')->url); echo $fu->render(); --- @pwFoo I implemented FU on a PW 3.0.33 with the FURegisterEmailValidation module. The email is sent but empty. Using TracyDebugger, I dump $emailContentHtml and $emailContentPlain, they are always empty . // Load the plain / html email templates $emailContentHtml = wire('page')->render(wire('fu')->getFile('validationEmail.php', 'templates'), $vars); bd($emailContentHtml); it return : "" (empty string) Link to comment Share on other sites More sharing options...
pwFoo Posted September 15, 2016 Author Share Posted September 15, 2016 Hi @flydev, is it just PW 3.0.33 related? I haven't tested it with PW3... Link to comment Share on other sites More sharing options...
flydev Posted September 15, 2016 Share Posted September 15, 2016 I dont know, let me test on a 2.7 and 2.8, I will give you feedback. edit: installing the two version... edit 2: on 2.7.2, 2.8.33 and 3.x, after installation of the FURegisterEmailValidation, it give this error when accessing the frontend page : Fatal error: Call to a member function attr() on a non-object in [...]\site\modules\FrontendUser\FrontendUser\FrontendUserRegisterEmailValidation.module on line 160 Commenting the line 160, the form is rendered on the frontend page. Email testing - @pwFoo there are the results : on 2.7.2 : After filling the form, the email is sent and it contain all the information. It works. on 2.8.33 : After filling the form, the email is sent and it contain all the information. It works. on 3.0.33 : After filling the form, the email is sent and is empty. It do not works. Link to comment Share on other sites More sharing options...
flydev Posted September 16, 2016 Share Posted September 16, 2016 (edited) Today I managed to get it working for the three version. Tested. In the file FrontendUserRegisterEmailValidation.module line 110 I replaced the following code : // Load the plain / html email templates $emailContentHtml = wire('page')->render(wire('fu')->getFile('validationEmail.php', 'templates'), $vars); by this code : // Load the plain / html email templates $file = wire('fu')->getFile('validationEmail.php', 'templates'); $emailContentHtml = wireRenderFile($file, ['options' => $vars], ['default_path' => '']); As wireRenderFile was introduced in ProcessWire 2.5.2, there is no problem of compatibility. We can now receive email validation on PW 3.x with all information to create new user account Edited September 16, 2016 by flydev Tested on 2.7.2 / 2.8.x / 3.x 3 Link to comment Share on other sites More sharing options...
modifiedcontent Posted September 16, 2016 Share Posted September 16, 2016 I also get a fatal internal server error with FrontendUserRegisterEmailValidation.module in PW 3.0.33: Quote Error: Call to a member function attr() on a non-object (line 160 of [...]/site/assets/cache/FileCompiler/site/modules/FrontendUser/FrontendUser/FrontendUserRegisterEmailValidation.module) Line 160 in my case, not 110. Line 160 is: Quote $form->get('EmailPreValidation')->attr('disabled', true); Removing that line "fixes" the error, shows the form. Removing everything from the arrow as well. If you try to register, an email gets sent, but it is empty. Changing 'true' to 'false' had no effect. A combination of flydev's solution for line 110 + removing everything from the -> sign, does seem to fix the error. An email does get sent with a validation token. And then the user has to pick a password? And then what? Is there supposed to be a second email, with 'Welcome, now log in here ...'? Or should I structure the form/pages in such a way that picking a password also logs the user in? Is there really no complete working implementation example somewhere? I tried 'check for updates' on the FrontendUserRegisterEmailValidation.module , but get Quote Error reported by web service: Unable to find that module Once you have a working process, how would you style and extend the forms? Beyond using the available classes and ids for CSS. Is there a way to get control over the html? I never use list tags, <li etc., for forms. I'd like to rewrite it to something like this: <div><input placeholder="label text here" ... /></div> Link to comment Share on other sites More sharing options...
pwFoo Posted September 17, 2016 Author Share Posted September 17, 2016 @modifiedcontent // krisj / https://processwire.com/talk/topic/9811-frontenduser-login-logout-and-register-users-members/?p=122040 - $form->remove($form->get('EmailPreValidation')); //hide the token field before the email is sent = less distraction + //$form->remove($form->get('EmailPreValidation')); //hide the token field before the email is sent = less distraction $form->get('EmailPreValidation')->attr('disabled', true); @flydev // Load the plain / html email templates - $emailContentHtml = wire('page')->render(wire('fu')->getFile('validationEmail.php', 'templates'), $vars); + //$emailContentHtml = wire('page')->render(wire('fu')->getFile('validationEmail.php', 'templates'), $vars); + $file = wire('fu')->getFile('validationEmail.php', 'templates'); + $emailContentHtml = wireRenderFile($file, ['options' => $vars], ['default_path' => '']); Link to comment Share on other sites More sharing options...
pwFoo Posted September 17, 2016 Author Share Posted September 17, 2016 Please test it with FrontendUser: 0.9.3 and report back. 1 Link to comment Share on other sites More sharing options...
flydev Posted September 17, 2016 Share Posted September 17, 2016 1 hour ago, pwFoo said: Please test it with FrontendUser: 0.9.3 and report back. Perfect, it work fine on the three versions. Thanks for the update Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now