Jump to content

modifiedcontent

Members
  • Posts

    286
  • Joined

  • Last visited

Everything posted by modifiedcontent

  1. I am not 100% sure if or to what degree my issue is related. Apologies if this turns out to be thread hijacking: I get logged out constantly at certain wifi locations; '_The Cloud' wifi point that many pubs in London have and, I think, all similar public wifi systems that open a browser where you have to leave your email or click on a connect button if you are a returning customer. Does that sound familiar to anyone? Is there a way to make my PW sites work at these locations? Is the solution somewhere in the previous posts here? I have trouble following the thread. 'Enabling SessionHandlerDatabase should instantly get rid of the problem'? How would I do that? 'session fingerprint config setting'?
  2. I had to add this... && $_FILES['headshot']['name'][0] != '' ...to this bit... if($input->post->img_upload && $_FILES['headshot']['name'][0] != '' ) { That was the only way I could find to prevent Internal Server Error if someone clicks submit without selecting a file. Is there a better, more Processwire way to do this? $input->post->headshot etc. doesn't work.
  3. ankh2054, we can't get this code to work here. What are we doing wrong? Shouldn't it be possible/easy to get the same image upload UI as in the admin area? Or some other cropping or centering tool? Any jquery script would work or mess up the system?
  4. Edit: I had posted here because I thought this didn't work: But it does work. The images just don't end up where I expected them - the 'headshots_uploads' directory is supposed to stay empty? You can see the result of the upload with: There should be a headshot/avatar field in the user template. It can get confusing if you have some kind of custom user profile page; you have to make sure you get the avatar of the relevant user instead of the logged-in user. And the upload is saved to $user, not the $page the form is on. There is no way to get the nifty image upload from the admin area on the front end? Edit: I have added $user->headshot->removeAll(); because I kept seeing old avatars. This way you can only have one image in the field/array, so you can't have a feature where the user can swith between uploaded avatars. Is there a more elegant way to "refresh" or make sure that only the latest modified profile picture is shown? Edit2: If you click Submit without selecting an image, you get an Internal Server Error. So I guess you need a check if the input field is empty or not. How do you do that in Processwire? What I have tried so far - adding && $input->post->headshot to the first if statement etc. - didn't work.
  5. Nevermind. Long post deleted here. Sorted it out here.
  6. I am trying to do the same thing as adrianmak - had you figured out how to do this? Do you need the 'current password' field? I think 'new password' and 'confirm new pass' should be enough if the user has access to this form. Or am I missing something? You can use $user->pass->matches($inputPass) to check the input, but, to be clear, there is no PW function or similar that adds the same 'change password' thing that is in the admin profile edit? Password is the same as any other input field? You can save a password from a form input simply with this? ... $user->pass = $sanitizer->text($input->post->pass); $user->save(); And then PW takes care of the hash stuff? The hash stuff is confusing... Or are there specific password checks or processes to take care of? Edit: I see there is an InputfieldPassword.module, probably part of the forms API that I still can't wrap my head around. I guess you should use that somehow? Adding this, as a quick test, produces a server error:
  7. I keep running into $p = new Page(); and $u = new (); , but how do you update an existing page or user? 'current Page()'? Do you have to define $p = current page? What is the proper process? Edit: Nevermind. I guess this is the basic process to update an existing user?
  8. Thanks Zeka! This works: function qa_get_public_from_userids($userids) { global $users; $useridtopublic = $users->find('id=' . join('|', $userids))->explode('fullname', ["key" => "id"]); return $useridtopublic; }
  9. $userlist is not an array - at least my version via $users-> and global. var_dump($userlist) produces a server error. echo $userlist displays a piped string of ids. I can't get wire() to work in the external script. In which file should I add 'namespace ProcessWire'? The function is in another script that bootstraps PW by including the index. Shouldn't that be enough? The var_dump(wire()->users->find('id>0')) results do not look like anything my script could use. Is there no simple way to convert a piped string into an array?
  10. I keep getting 'PHP Fatal error: Call to undefined function wire() ...', with or without '$config->useFunctionsAPI = true;' in the config.php This version had no error, but returns an empty (0/null) array: I have been trying variations of this for the last two days, going in circles. I have a custom field 'fullname', so ignore that, could be 'name' instead. Will try again later... I'd like to try array_combine or something like that. I'd need two valid arrays. var_dump($userids) returns a healthy looking array. Getting that second array of fullnames is my problem. Or would it work if I can get wire() to work? $userlist is not an array, so that foreach can never work?
  11. Thank you abdus ! I had come across array_combine, but had no idea how to use it. I have now tried something like this: function qa_get_public_from_userids($userids) { global $users; // build a selector like id=1|2|3|4 $userlist = $users->find('id=' . join('|', $userids)); $names = $userlist->getProperty('fullname'); // create an array of [username => userid] $useridtopublic = array_combine($userids, $names); return $useridtopublic; } That still doesn't work; $userlist is not an array, but a "piped string" (?) of user ids. Same as $userids, but another format. Can $users->find be used with multiple selectors? Or did you really mean to use 'users()->find'? users()->find produced server errors for me. The $names line should probably be a foreach loop? How do you get a key/value array out of a foreach loop? That is one of my main questions that I keep running into. Will try again tomorrow...
  12. I am trying to integrate another script, Questions2Answer, with Processwire user management. The script needs an array with key/value pairs for user->name => user->id The script provides an array $userids with active user->ids that looks like this var_dumped for a page with two users: array(2) { [0]=> int(1107) [1]=> int(41) } How can I take $userids, find the corresponding $user->names in Processwire as values and then return that to Q2A as a clean key/value array? This is probably basic PHP, but I have tried so many variations that I now completely lost the plot. Any pointers appreciated.
  13. Thanks! This worked: $news = $pages->find("template=post, sort=-created");
  14. Dumb question coming up. I can't get sorting to work. I show child pages (posts) of a parent page (news) on the homepage with this in the template: $news = $pages->find("template=post"); foreach($news as $post) { ... Sort order setting in the template or page is apparently ignored. The sort order is correct in the admin area, but shows up wrong on the home page. What am I missing?
  15. adrian's solution works well, but causes an internal server error on one page that loads an external script: 2017-04-02 07:06:03 guest http://mysite.com/http404/ Error: Cannot redeclare setRedirect() (previously declared in /var/www/html/site/assets/cache/FileCompiler/site/ready.php:5) (line 5 of /var/www/html/site/assets/cache/FileCompiler/site/ready.php) Renaming the function did not fix it. Don't have time to dig into this right now. Leaving this note here and will report back...
  16. Thanks adrian ! Yes, that does seem to work. I have seen another hooked function like this: $wire->addHookAfter ... Is wire() and $wire and wire-> etc. all the same? What's what? I guess I'll have to study up on that... And would this work within the templates folder, in a functions.php or something like that? I'll have to try that... The ready.php file is awkward.
  17. Thanks BitPoet. I get server errors when I put this in ready.php. - should it go there or could you also put it in a functions.php file within the templates folder? This is the error I get on logout: Error: Uncaught Error: Call to a member function get() on null in /var/www/html/site/ready.php:6 Stack trace: #0 /var/www/html/wire/core/WireHooks.php(777): setRedirect(Object(ProcessWire\HookEvent)) #1 /var/www/html/wire/core/Wire.php(402): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessLogin), 'executeLogout', Array) #2 /var/www/html/wire/core/ProcessController.php(244): ProcessWire\Wire->__call('executeLogout', Array) #3 /var/www/html/wire/core/Wire.php(374): ProcessWire\ProcessController->___execute() #4 /var/www/html/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___execute', Array) #5 /var/www/html/wire/core/Wire.php(402): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessController), 'execute', Array) #6 /var/www/html/wire/core/admin.php(113): ProcessWire\Wire->__call('execute', Array) #7 /var/www/html/wire/modules/AdminTheme/AdminThemeReno/controller.php(13): require('/var/www/html/w...') #8 /var/www/html/site/templates/admin.php(15): require('/ (line 6 of /var/www/html/site/ready.php) This error message was shown because: you are logged in as a Superuser. Error has been logged. This version produces no errors, but doesn't do anything either: wire()->addHookBefore("ProcessLogin::executeLogout", null, "setRedirect"); function setRedirect(HookEvent $event) { $event->object->setLogoutURL('/'); } Probably unrelated, but does it make any difference if you do wire()->... or wire->... ? Why is redirect to homepage not default behavior anyway?! The login form in the admin area is the last place you want to be when you log out. Wordpress has the same annoying illogical default behavior. Is there some obscure reason why it makes sense?
  18. I have tried to do this with: $finduser = $users->get( $input->post->email ); $user = $finduser->user; But get a server error. Is the approach obviously wrong or should I look for silly syntax errors? Email address should be unique imho. More and more organizations, including banks etc., use email address as the main unique identifier. Edit: $finduser->user; should have been $finduser->name
  19. I think you can create a simple logout link with <a href="admin/login/logout">log out</a> But it redirects to the login form in the admin area. Can I hook into logout and change the redirect? Default redirect home would make sense. Or is the way to do this still to create a logout template + page with session->logout() and a redirect?
  20. @hollyvalero, just add $mail->send(... etc. at the point in the script where you want the admin notification sent. See example in here. Or like this - apparently better for HTML mail:
  21. These new users template options are probably going to be helpful in more advanced user management. Via apeisa.
  22. For someone just coming in from the Wordpress world it is tempting to look for a module/plugin that does everything out-of-the-box to avoid having to learn about the form API, hooks, PW native features, etc. If I have to know all that before I get anything usable, I might as well skip your FrontendUser module + two required helper modules that may or may not be compatible with the latest PW version and just use those PW native features to put my own solution together.
  23. @netcarver, if you follow the thread back, you'll see that I actively tested pwFoo's module. It worked very well, except for a few issues that did not get resolved. March 7 pwFoo mentioned that 'the module isn't compatible with the latest PW version'. I got back into this thread to finish the solution, get a complete working process. I basically have one here, but don't know how to turn it into a module or integrate it with pwFoo's. So I think it is up to @pwFoo to return to his thread and solve outstanding issues, maybe by using or rejecting some of what we discussed above. BTW, this wirePopulateStringTags() solution would also be a great addition to a FrontendUser/member registration module, to make the system activation and welcome email messages managable as regular fields.
  24. Thank you for not taking this personal, @benbyf. In my solution here I use a custom function for username creation from a fullname. I haven't added a check for diplication yet - and kinda hope the system would catch that somewhere. I have used a similar username-from-fullname process in Wordpress for years and never had a problem there. Apparently in Processwire 'it is not a requirement that the "email address" field of a user page be unique'. I think I have tried the username-from-email solution myself when I first tried to develop this process in Wordpress, with similar results.
  25. I also get this error and adding that line to config.php doesn't get rid of it. Where in the config.php file should I add it? Does the location matter? I have also added it at the top of my functions.php file. Makes no difference either. Where is init.php? Aren't those other files core files that you are not supposed to edit?
×
×
  • Create New...