Jump to content

Recommended Posts

Posted

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!

Posted

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
Posted

@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!

Posted

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!!

Posted
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
Posted

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
Posted
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
Posted

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
Posted

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

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
×
×
  • Create New...