• Content count

  • Joined

  • Last visited

Community Reputation

19 Good

About modifiedcontent

  • Rank
    Sr. Member

Recent Profile Visitors

851 profile views
  1. How do you get the same 'set password' form/input fields on the front-end as in the admin area? I have a working front-end version, but the admin version has some nifty stuff around it. Should be easy to get the same on the front-end, right?
  2. 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'?
  3. I had to add this... && $_FILES['headshot']['name'][0] != '' 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.
  4. 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?
  5. 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.
  6. Nevermind. Long post deleted here. Sorted it out here.
  7. 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:
  8. 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?
  9. 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; }
  10. $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?
  11. 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?
  12. 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...
  13. 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.
  14. Thanks! This worked: $news = $pages->find("template=post, sort=-created");
  15. 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?