X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   How to get email address of logged on user? (https://forum.x-cart.com/showthread.php?t=65528)

arren123 11-30-2012 08:58 AM

How to get email address of logged on user?
 
Sorry, I'm still new to editing X-cart. Hopefully this will be an easy one. I just want to get the email address of the logged on user so I can build an html link.

I'm editing the new archive template
/common_files/modules/News_Management/customer/news_archive.tpl

Here is the code I've written for test purposes.

Code:

{capture name=unsubdialog}
<table cellspacing="1" class="data-table">

        <tr>
          <td><a href="https://store.sweet-sugar-gliders.com/mail/unsubscribe.php?email={$email}">Click here to unsubscribe</a></td>
        </tr>       
        <tr>
            <td>{$lng.eml_unsubscribe_information}
{$http_location}/mail/unsubscribe.php?email={$email}</td>
        <tr>
      </table>
{/capture}
 {include file="customer/dialog.tpl" title="Unsubscribe" content=$smarty.capture.unsubdialog}


What do I put in place of {$email} so it will return the e-mail address?

Arren
X-Cart Pro v 4.5.4

totaltec 11-30-2012 11:29 AM

Re: How to get email address of logged on user?
 
If you are using email as username (which I recommend), then just try {$login}.

Another one to try if you are using product notifications: {$prod_notif_prefilled_email}

On some pages, like my account and checkout areas you can use {$userinfo.email}

Try using webmaster mode to learn what variables are assigned to the page in question.

arren123 11-30-2012 11:39 AM

Re: How to get email address of logged on user?
 
Thanks for the tip, but unfortunately the e-mail address is not being used as the username right now. I have to do a cleanup of users before I can switch to that mode.

I ran webmaster mode, but didn't see any variables for the email address when I was on the page.

So.. I guess my question is,
How do get get the e-mail address of the logged on user from the database and return it to a template so I can use it in an html link?

totaltec 11-30-2012 12:09 PM

Re: How to get email address of logged on user?
 
If we could do this from a page that had $userinfo assigned like the my account page, then this would be a snap.

It's not going to be that hard, but it is going to require some PHP and a database query. First, lets determine what php page you are working with. Can you provide a link to the page? What does it say in the address bar? Is it news.php?

If so then we are going to have to place some code in that php file, to query the DB and assign it to smarty. Open up news.php
and try adding this to the bottom:
Code:

if (!empty($logged_userid))
    $smarty->assign('userinfo', func_userinfo($logged_userid, 'C'));


Add it right before:
Code:

func_display('customer/home.tpl', $smarty);

Be sure to make changes like this on your dev/test site first, and make backups if the original files, and note the change in your changelog.

arren123 11-30-2012 04:01 PM

Re: How to get email address of logged on user?
 
Thanks! That worked like a charm!

Arren:D/


All times are GMT -8. The time now is 06:51 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.