Adding profile fields

Pending
Advanced Security - PHP Register/Login System Advanced Security - PHP Register/Login System September 11, 2020
Login to reply
Milos Stojanovic Support Agent
1 month ago

Hey Michael,

In the future, please create a separate ticket for different topics. It's easier for me to track it that way.

As for the OAuth login settings, I'm not sure if you are referring to Google or Facebook. For Facebook you should use

https://yourdomain.com/socialauth_callback.php?hauth_done=Facebook

And for Google

https://yourdomain.com/socialauth_callback.php?hauth.done=Google

Regards,
Milos

Michael Coy
1 month ago

Hi again. For whatever reason I can get this to work on localhost but not
on a live demo.

URL Blocked: This redirect failed because the redirect URI is not
whitelisted in the app’s Client OAuth Settings. Make sure Client and Web
OAuth Login are on and add all your app domains as Valid OAuth Redirect
URIs.

What can I do to fix this? What would the Valid OAuth Redirect URIs be?

https://demo4.netwizarddesign.com.au/michael/mega-anchor/ is the demo

Milos Stojanovic Support Agent
1 month ago

Hey,

No problem, I'm glad it's working as expected now! :)

Regards,
Milos

Michael Coy
1 month ago

Thanks Milos I got it working. Nice system by the way.

Milos Stojanovic Support Agent
2 months ago

Hey Michael,

The email sending configuration looks good. Are you able to send emails using these SMTP credentials from some other app or some other email client?

If you are 100% sure that everything is configured properly, can you please send me a link to your website so I can check? Make sure that you have DEBUG set to true in your ASConfig.php file.

Regards,
Milos

Michael Coy
2 months ago

// EMAIL SENDING CONFIGURATION
// Available MAILER options are 'mail' for php mail() and 'smtp' for using
SMTP server for sending emails
define('MAILER', "smtp");
define('SMTP_HOST', "sys03.managedpremiumhosting.com.au");
define('SMTP_PORT', 465);
define('SMTP_USERNAME', "megaanchor@managedpremiumhosting.com.au");
define('SMTP_PASSWORD', "XXXXXXXXX");
define('SMTP_ENCRYPTION', "TLS"); ///Is this right?

define('MAIL_FROM_NAME', "Mega Anchor");
define('MAIL_FROM_EMAIL', "noreply@mega-anchor.com");

What could be the problem? I am not seeing anything obvious in DEBUG.

Milos Stojanovic Support Agent
2 months ago

Hey,

The problem is most likely with the confirmation email, probably because your server is either not configured to send emails or, if you are using an external SMTP server, the app is unable to connect to it. 

I'll recommend you to check the Developer Guide to see how you can debug AJAX requests and then use that technique to see what is wrong with the registration.

Kind regards,
Milos

Michael Coy
2 months ago

Hi Again. I am experiencing an issue. See attached. After registering the
user is added to the DB but the button just says creating account.. and
nothing happens. What could be the problem?

Michael Coy
2 months ago

Thanks Milos for the detailed explanation. I will try and sort it out now.

Milos Stojanovic Support Agent
2 months ago

Hey Michael.

Here is the high-level overview of what you need to do, and I will suggest you to go through the code for existing fields to see how it works:

1) You need to add the HTML for that new input field that you want to add.

The HTML for the user details form is within the profile.php file, so just edit that file and add one more text input field there. Make sure that you set the "name" attribute for it since you will use that in the next step. For our example, let's say that you added "date_of_birth" as a name attribute for this field

2) Update the JavaScript file that's responsible for sending the form data to the server using AJAX.

The file that you need to edit is "assets/js/app/profile.js" and you'll need to extend the handler for "#update_details" button click which starts on line 44. All you need to do is to add one more item into the "details" object. The key there should be the name of your database column (let's say you also named it "date_of_birth") and the value is the value for your newly added form element.


Here is an example:

details: {
    first_name: form['first_name'].value,
    last_name: form['last_name'].value,
    address: form['address'].value,
    phone: form['phone'].value,
    date_of_birth: form['date_of_birth'].value, // <-- this is what we added
}

And that's really it, it will then be sent to the ASAjax.php file and trigger the "updateDetails" method from ASUser class, which will then update the data in the database.

Kind regards,
Milos

Michael Coy
2 months ago

Could you explain how I could add additional user_details fields. For example: Date of Birth. I cannot work out how to save that to the database. I have created the necessary column in the DB.