MarcoPLY

Edit User-login profile

Recommended Posts

HI.

I don't understand how I can customize the user-login profile. Some one can help me?

I use the login/registration module. At moment user can only change password and email. I don't understand how add this other fields: I would like the user make the registration can edit their name, surname, city and other information.  If possible, the best things would be to use the same classes of Padloper in the way that during the checkout process the fields is are already filled out.

Thank you!

Share this post


Link to post
Share on other sites

Hello Marco,

Not really a direct answer, but you can find some information in this thread

 

 

To add custom fields, you have to add your custom fields to the user system template. After that, Go to the LoginRegister module settings and add the fields to the profile options.

Your users will be able to edit their profile with the new customs fields :

 

template.png.5d5bd25835eb715ae95da69a9ef4af9b.png

 

LR.thumb.png.ec547116eddb1b54565460dbb805bdef.png

 

  • Like 5

Share this post


Link to post
Share on other sites

@flydev :lol: Thank you!

It's easy! nice. Sorry I'm new in pw and I don't know a lot of commands, hook and api. Now I can add this  also in the Registration Form, perfect!
But if I want edit the page to change the html render, want I need to do? I can make a separate template or I have to to inside the module ?

Thank you again!

Share this post


Link to post
Share on other sites
11 minutes ago, MarcoPLY said:

But if I want edit the page to change the html render, want I need to do?

You can only modify the markup/styles with hooks, CSS and JS - you can find some examples in the post I linked earlier - and I advice you to not modify the module himself in case update happen 😬

More info there : https://github.com/ryancramerdesign/LoginRegister#customization

 

  • Like 2

Share this post


Link to post
Share on other sites

Yes correct, thank you. I will make the hooks to changes the markup. I think with a little practice I will be able to do it! 

I was thinking of modifying the module because I want add in the log-in page also a link to other page: Purchased Products. But I will try to make also this with a hook.

Thank you!!

Share this post


Link to post
Share on other sites
12 minutes ago, MarcoPLY said:

I think with a little practice I will be able to do it! 

Sure !  👍

 

To get you started, I hope I am not spoiling things, you can add a link quite easily. In the file ready.php put :


wire()->addHookAfter('LoginRegister::buildLoginForm', function ($event) {
    $obj = $event->object;
    $form = $event->return;
    $f = new InputfieldMarkup();
    $f->markupText = "<a href='". wire('pages')->get('/purchased-products/')->url ."'><h3>Purchased Products</h3></a>";
    foreach ($form->children as $field) {
        if ($field instanceof InputfieldSubmit) { // find the submit button
            $form->insertAfter($f, $field);      // insert the InputfieldMarkup after the button
        }
    }

    $event->return = $form;
});

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi @flydev, ahah no problem I can hear the whole story :) !! joke. Thank you for your starting point! 

If I have understand well this hook will add a new link inside the login from. exact? probably there are something I do wrong on hooks, I tried to do in inside the buildLoggedInLinks but it not work. 

Anyway make this hook it's bit hard for me at moment. I did not understand how hooks work, so, following the instructions in the hook page I have try to do some more easier hook, but not work, where I wrong ? (try to move the logout link next to the name)

 

wire()->addHookAfter('LoginRegister::renderMessage', function ($event){
  // $value contains the full rendered markup of a $page
  $value  = $event->return;
  $value = str_replace( "<p class='LoginRegisterMessage'>" . $this->wire('sanitizer')->entities($message) . "<a href='$page->url?logout=1'>" . $this->_('Logout') . "</a></p>", $value);
  // set the modified value back to the return value
  $event->return = $value;
});

 

 

  • Like 1

Share this post


Link to post
Share on other sites
35 minutes ago, MarcoPLY said:

If I have understand well this hook will add a new link inside the login from. exact?

More precisely, it create a new InputfieldMarkup and add it to the LoginRegister form. You can put any markup you want inside this field.

 

35 minutes ago, MarcoPLY said:

Anyway make this hook it's bit hard for me at moment. I did not understand how hooks work, so, following the instructions in the hook page I have try to do some more easier hook, but not work, where I wrong ?

 

Compare and try with this code :

wire()->addHookAfter('LoginRegister::renderMessage', function ($event){
    $message = $event->return; // get the original message
    // bd($message); // use TracyDebugger to get whats inside the variable - now we know how to modify the markup
    $message = str_replace("</p>", " (<a href='". wire('pages')->url ."?logout=1'>" . __('Logout') . "</a>)", $message); // replace markup
    $event->return = $message;  // set the modified value back to the return value
});

 

https://processwire.com/blog/posts/introducing-tracy-debugger/

https://www.google.com/search?q=processwire+get+started+with+hooks

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Yes this work! I learn now. I start to understand how  use the hook! :)  Thank you very much! I will try to do more complex hook.  

But I can use any php string functions ?  like implode() 

  • Like 1

Share this post


Link to post
Share on other sites

Yes everything, PHP functions and also the ProcessWire API.

Do not hesitate to install TracyDebugger to debug your app and speed up development ;)

  • Like 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jacmaes
      I'm sure it's been asked before on the forums, but I haven't found a relevant answer after multiple searches.  I have a form on the frontend that mirrors the user profile on the backend. After logging in, I want the user to be able to edit multiple fields on his or her profile. For simple text entries (e.g. First Name, Street Address, Phone Number or Email), and single options (e.g. radio buttons for Gender: male or female or select dropdowns for a Country list), I have no issue and everything works fine: the user first fills out the form then can go back and update whichever field they want. That's standard profile editing stuff from the frontend.
      But I hit a roadblock when I want to offer multiple choices. For example, I have a Select Options field set up to show multiple checkboxes for choosing various types of driver's licences. With the following code (edited for brevity):
      $licence_types = array('B1', 'B', 'A1', 'C1', 'D1'); // same options as defined in my select options field foreach($licence_types as $licence) { $content .= "<label><input type='checkbox' name='licences[]' value='$product'> $licence</label>"; } .... $user->of(false); $user->licences = $licences; $user->save(); $user->of(true); the user can successfully submit this info from the frontend form:

      But now how do I show them the result  of what they submitted when they go back and want to update their profile from the same form? In other words, how do I insert the checked='checked' (or simply 'checked') HTML in the previously selected checkboxes?  For example, if they selected the first two options –B1 and B– in the example above, how do I make these two checkboxes ticked?
      With the following loop, I can show the previously selected checkboxes:
      foreach($user->licences as $licence) { $content .= "<label for='$licence->id'> <input name='licences[]' type='checkbox' id='$licence->id' value='$licence->id' checked>$licence->title</label>"; }  
      How do I merge the two loops so that they see this, as expected:

       
      Maybe with in_array()? Any help would be greatly appreciated.
       
       
    • By Mustafa-Online
      Hi Everyone, It's Been a While Since i Started Working With The "Super Lovely ProcessWire" & I Absolutely In Love With It .
      But, sometimes i feel lost, because the lack of tutorials "Specifically Videos" - i wish  there will be more tuts made by the community & from the ones who have
      The Experience.
      1- Regarding to the user profile, is there any way to show fields in Tabs ?? or if there in way to attach pages to user will be fine
      2- Markup-Regions : Where i can find the Docs that are Related to them ??
       
      Thanx
    • By mrkhan
      Hello,
      i have managed to login and logout and change password for user from PW front end with the help of 
      https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/
      many thanks to @ryan
      but now i need it little advance
      1. i want to have option for login users to save some pages as FAV and can see in their profile.
      how exactly i can do that ?
      do i need to create some fields in users Template , how login users can press button on page to put as FAV & if he is not logged in it goto LOGIN Page.
      2. and User Name and Phone Number and Pic in user profile.
      Thanks
    • By Guy Verville
      Hi,
      This question is perhaps dumb. How can a user change his/her profile? I get this empty window when logged as un regular user.

      The fields are set to be vewable in the User template.

      There will be numerous users that will be able to write blog entries. What if I want to restrict tue editing to own's content?  In the following example, the user logged is not the author of the page. So he shouldn't be able to edit it.