Loading...
 

Need

I needed to use the email address of the current user to fill out a form field. (long story as to why)

Explanation

There exist some Wiki Argument Variables that allow one to use some variables that are part of the tiki current instance. For example {{user}} will display the userid of the current user: . My first idea was to implement the same thing for to display the email id of the current user.

It is generally considered a bad idea to insert email addresses into wiki or web pages as spammers can scrape and use them. I believe this is why the idea is frowned upon. So thanks to Jonny's suggestion I came up with the following solution instead.

Method

  1. Add the following custom.php to your tiki language directory, mine is in lang/en/ or lang/en-uk/
    <?php
    // custom.php pmc 2011/05/11
    global $user;
    if (!empty($user)) {
      global $userlib, $smarty;
      $email=$userlib->get_user_email($user);
      //create smarty variable assign it the value of the current user's email address
      $smarty->assign('curremail', $email); }
  2. To use the smarty variable
    1. using Smarty plugin
      {SMARTY(name=>eval, var=>"{$curremail}")}{SMARTY}
    2. used in a smarty template
      email id is {$curremail}

Example

This is how I used it via smarty plugin and div plugin and jquery plugin to pre-fill an html form field which is within html plugin. It is shown here in three parts that must be within the same page. Extraneous information has been removed &/or replaced with blah or ....

  • html <form>
    {CODE(colors=bash)}

{HTML()}
<form method="post" action="http://blahblah...">
Your E-mail address: <input type="text" name="email" size="30" , id=emailid>
...
</form>
{HTML()}
{CODE}

  • retrieve field value, assign it an id for use in jquery
    {DIV(class=hidden, id=emailactual)}
     {SMARTY(name=>eval, var=>"{$curremail}")}{SMARTY}
    {DIV}
  • insert the field value in the form
    {JQ()}
    if (!$jq("#emailid").val()) { $jq("#emailid").val($("#emailactual").text()); 
    }
    {JQ}

Page last modified on Wednesday 11 May, 2011 15:05:00 GMT-0000

doc.tiki.org

Get Started

Admin Guide User Guide Bootstrap in Tiki

Keywords

Keywords serve as "hubs" for navigation within the Tiki documentation. They correspond to development keywords (bug reports and feature requests):

Accessibility (WAI and 508)
Accounting
Articles and Submissions
Backlinks
Banners
Batch
BigBlueButton audio/video/chat/screensharing
Blog
Bookmark
Browser Compatibility
Link Cache
Calendar
Category
Chat
Clean URLs
Comments
Communication Center
Compression (gzip)
Contacts (Address Book)
Contact us
Content Templates
Contribution
Cookie
Copyright
Credit
Custom Home and Group Home Page
Date and Time
Debugger Console
Directory of hyperlinks
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
Draw
Dynamic Content
Dynamic Variable
External Authentication
FAQ
Featured links
File Gallery
Forum
Friendship Network (Community)
Gmap Google maps
Groups
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
Kaltura video management
Karma
Live Support
Login
Logs (system & action)
Look and Feel
Mail-in
Map with Mapserver
Menu
Meta Tags
Mobile Tiki and Voice Tiki
Mods
Module
MultiTiki
MyTiki
Newsletter
Notepad
Payment
Performance Speed / Load
Permissions
Platform independence (Linux-Apache, Windows/IIS, Mac, BSD)
Polls
Profiles
Profile Manager
Report
Toolbar
Quiz
Rating
Feeds
Score
Search engine optimization
Search
Search and Replace
Security
Semantic links
Shadowbox
Shadow Layers
Share
Shopping cart
Shoutbox
Slideshow
Smiley
Social Networks
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Stats
Surveys
Tags
Task
Tell a Friend, alert + Social Bookmarking
TikiTests
Theme CSS & Smarty
Trackers
Transitions
TRIM
User Administration including registration and banning
User Files
User Menu
Watch
WebDAV
Webmail
Web Services
Wiki History, page rename, etc
Wiki Syntax
Wiki structure (book and table of content)
Workspace
WSOD
WYSIWYCA
WYSIWYG
XMLRPC

Tiki Newsletter

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other news!
Contribute to Tiki