Accessing PHP variable in .tpl

Sometimes situation may arise when you want some PHP code in tpl. Following piece of code will show how to achieve this.

{php}
    global $current_user;
    $this->_tpl_vars['current_user_email'] = $current_user->email1;
{/php}

Now use ‘current_user_email’ variable as follows in tpl.

<input type="text" id = "current_user_email" name="current_user_email" value='{$current_user_email}'> 

Hope you find this blog post helpful.

Feel free to add comments and queries, that helps us to improve the quality of posts.

You can contact us at info@infotechbuddies.com

Thank you.

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *