-
Posts
1,699 -
Joined
-
Last visited
-
Days Won
14
Everything posted by renobird
-
Admin Data Table and rows starting with numbers cause problems
renobird replied to teppo's topic in General Support
I have this same problem as well. All my user names are numbers. -
Nice work Soma! When viewing the English version, the Culinary link towards the bottom takes you back to the German version. The others seem to work correctly. Overall, a really lovely site.
-
Yep, works great! In case anyone is following along, my original example is updated and working correctly. Thanks Ryan!
-
Thanks Ryan, Much appreciated. I'll test on my site and then update the code example accordingly.
-
Hi Ryan, Session variables and error handling aren't things I'm all that good at, so any guidance is appreciated. I'm just working off the cheatsheet and hacking my way around. I realize now that I initially had $error =""; in there because I thought that was the proper way to avoid the undefined variable. When I tried setting it up like you suggested: if($session->login($user, $pass)) { // login successful $session->redirect($page->path); }else { $session->set('error', ""); $session->set('error', "Login Failed. Please try again, or use the forgot password link below."); } echo "<p class='error'>".$session->get('error')."</p>"; I get this error if I enter an incorrect password more than once. Warning: Invalid argument supplied for foreach() in /x/xxxx/xxxxxxxx.edu/htdocs/wire/core/Session.php on line 60 However, when I do it this way it seems to work properly. if($session->login($user, $pass)) { // login successful $session->redirect($page->path); }else { $error =""; $session->set($error, "Login Failed. Please try again, or use the forgot password link below."); } echo "<p class='error'>".$session->get($error)."</p>"; I'm sure there is a best practice for this, I just don't know what it is, so I fiddled around until I got it to work.
-
Thanks Nikola, Installing this update now.
-
Hi Ryan, Nice catch. Yeah, no sense setting a session variable after the redirect. That entire if/else had a bunch of stuff I was commenting in/out while I was testing, I did a poor job of cleanup. I updated my code above, so it's correct for anyone that uses it.
-
Ryan, A meetup in the context of another conference is a great idea, and a good place to evangelize.
-
Much appreciated here as well @evan. Definitely something I'll make use of.
-
In case anyone is interested, Here's how I built a custom PW login. http://processwire.com/talk/topic/107-custom-login/#entry11290 I took Ryan's example and built on it from there. It handles the login/logout, and automatically redirects the user back to the original page they requested after they are logged in.
-
Ryan, Thanks this gave me a great place to start. I thought I'd share the version I created in case anyone finds it useful. • Single template for the login/logout. • Automatically redirects the user back to whatever page they originally requested after they login. ./includes/login.php <?php // Handle logouts if($input->get->logout == 1) { $session->logout(); $session->redirect($page->path); } // If they aren't logged in, then show the login form if(!$user->isLoggedin()){ // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect($page->path); } else { $session->login_error = 'Login Failed. Please try again, or use the forgot password link below.'; } } ?> <!DOCTYPE HTML> <html lang="en"> <head> <title>Custom PW Login</title> </head> <body> <form action='./' method='post'> <div class="login"> <? if($input->post->user && $input->post->pass) { echo "<p class='error'>" . $session->login_error . "</p>"; }?> <p><input type='text' id="user" name='user' placeholder='Username'/></p> <p><input type='password' id="pass" name='pass' placeholder="Password" /></p> <p><input type='submit' class="btn" name='submit' value='Login' /></p> </div> </form> </body> </html> <? die(); // don't go any further if not logged in } // end !logged in ?> In any template you wish to protect: <? require("./includes/login.php");?> To trigger a logout: <a href="?logout=1">Logout</a> Note: I'm using the HTML5 placeholder attribute. Browser support is not 100%. You may want to use labels instead, or use some jQuery (like I did) to add the placeholder text for browser that don't support it. SideNote: How do you get code indents to stick when posting? I'm having to go back and add spaces to each line. I use tabs when coding.
- 63 replies
-
- 17
-
-
Ryan, I'm helping to change that where I can. I'm sure everyone I know is sick of my PW evangelism.
-
Page hierarchy / template strategy for genealogical info?
renobird replied to MarcC's topic in General Support
Hey Marc, Page fields seem like a great fit for this. I'll be interested to hear how you end up pulling it all together. -
Field Name case sensitivity makes sense but tripped me up
renobird replied to alan's topic in General Support
Alan, Made that one a few times myself. Mostly when I get an itchy pinky finger and end up capitalizing something unintentionally. -
For a quick solution: • Populate the name and email inputs with the current user info via jQuery. • Hide name and email inputs via CSS For those who might be interested here's a quick rundown of what I did. jQuery to populate the fields var name = '<?php echo $user->name ?>'; var email = '<?php echo $user->email ?>'; $('#CommentForm_cite').val(name); $('#CommentForm_email').val(email); CSS to hide the fields and labels #CommentForm_cite, #CommentForm_email, .CommentForm_cite label, .CommentForm_email label{ display: none; } Keep in mind, I'm using this on a protected page, so all visitors will be logged in. You could add some logic to check if the user was logged in or not, and show the name/email fields to guests. You'd probably want to hide the fields and labels via JS instead of CSS in that case.
-
Hi Ryan, I'm trying to do something similar to Nikola — bypass the name and email inputs and just have the comment be attributed to the currently logged in user. I created an autoload module like you suggested above, but all my comments are now attributed to "guest" whether the user is logged in or not. I'd also like to do a $session->redirect('./'); on success instead of showing a message, but I'm a bit confused on how to achieve that without modifying the module. Any additional help on this would be appreciated. Update I found this post about how to do the redirect, so I was able to implement that part.
-
Does anyone know how to upload a form File threw the api
renobird replied to peterb's topic in API & Templates
If you are still having trouble, I can post some code to help when I"m back at work on Monday. Right now I have to make 2 dozen easter eggs. -
The IRC channel is great! Some IRC client options if you are on a Mac: Colloquy Textual
-
Hi Dave, Unless there's some method of showing profile info that I'm not aware of (entirely possible), you can choose to display or not display any profile information in your template. <h2><?=$user->name?></h2> <p><?=$user->job_title?></p> <p><?=$user->bio?></p> <p><?=$user->email?></p>
-
Dave, You can add whatever fields you want to the user template. I'm building a fairly complex user profile setup as well. Go to: Setup > Templates, at the top of the page open the "filters" area and enable "show system templates". Now you can add any of your fields to the user template.
-
Ryan, Many thanks for this module, I just used it to add 436 users. There were a small handful of things that weren't initially clear, so I detailed them below for anyone else trying to import users. If you plan to import passwords, you need to open the module and add FieldTypePassword to $fieldtypes protected $fieldtypes = array( 'FieldtypePageTitle', 'FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeFloat', 'FieldtypeEmail', 'FieldtypeURL', 'FieldtypeCheckbox', 'FieldtypeFile', 'FieldtypePassword', // add this line ); Since users are pages and all pages require a title, your CSV will need to have a title column. In my case, I duplicated all the usernames into that column — so name and title are the same. In order for title to show as a connection option during your import, you need to add the title field to the user template file. To do this, go to: Setup > Templates (open the filters area at the top, and choose "show system templates". Select the user template and add the title field. One other thing to note, be sure to have a roles column in your CSV with roles for each user. I forgot that during my first test import and all the users were set to guest. You should be all set to import your users.
-
With apeisa's help, I did manage to get this working. I'll post the code soon for anyone else that might need something similar.
-
Thanks, I'm going to explore that option now.
-
Hi Apeisa, Can you walk me through how it would reference each user? Would I have to manually create a new page for each user in that separate branch? I'll end up with about 200 users roughly, and they will come/go quite frequently. Is there a way to automate the reference? Sorry if this is rudimentary PW stuff.
-
I'm a bit stumped on how to approach this, so I'll just explain what I'm after and hopefully someone can point me in the right direction. I have a files field for my users so they can associate files with their profile. I'm looking for a way to also allow them to categorize or tag those files. My goal is to be able to call these files from the front-end. (i.e. get all files for User1 in CategoryA, or get all files for all users in categoryA). I suspect this is possible with PW, but I can't seem to figure out how. Any direction is much appreciated.