Display a customizable "this user is [online/offline]" status message in the User Profile page

Note from the moderator: Thank you for sharing the snippet with the Drupal community. In its current state the snippet might present security risks. See Writing secure code for a background on the most common problems.

Specifically, the second snippet

  • allows SQL injection because it uses user supplied data directly inside an SQL query without further checks. Proper use of Drupals database abstraction layer can prevent these attacks.

Example of db_query usage:

<?php
  db_query("SELECT * FROM {users} WHERE uid = $uid"); // INSECURE
  db_query("SELECT * FROM {users} WHERE uid = %d", $uid);
?>

--

PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Description

This php snippet adds a This user is [online/Offline] status message in the user profile page.

Dependencies: profile.module must be installed and enabled.

Usage

ARCHIVE: Insert user friendly "click here to add your.." links when user profile fields are left blank

PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Description

This php snippet displays a user friendly "click here to add your [profile field]" link when they are looking at their own profile page and have forgotten or not yet filled out some details.

The default settings with Drupal is to hide empty fields, so Users sometimes don't know they can add a field unless they look at the various EDIT MY ACCOUNT options.

The snippet checks to see if the person looking at the profile page is the same person or someone with ADMINISTER USERS permissions. It then checks to see if a field is not yet filled in and displays the "click here to add.." link if that's the case.

Dependencies: profile.module

Usage

  • For use in your user profile page override
  • Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file

Display a date related notice or countdown snippet

PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Description

This php snippet displays a special message, based on a date set in the user profile. It only displays for users with ADMINISTER USERS permissions or when a user is looking at his/her own user profile page.

The example below is a warning to Members that there are (x) days left before their membership expires. The same snippet maybe used for many applications.

Dependencies: profile.module must be enabled and a DATE field must be set in the user profile.

Usage

  • For use in your user profile page override
  • Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file
  • Change the name of the profile date field you are using. (Tip: go to administer -->> settings -->> profile and in the second column it will give you the field name.)
  • Tested and works with Drupal 4.5 and 4.6
  • Change the div class names or the prefix text to suit.

Display a Skype "Call me" or "leave a voicemail" button depending on Users' online/offline status

PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Note: There is also a Skype Support module.

Description

This php snippet adds a Skype: Call me! button to their user profile page if they are online or a Leave a voicemail! message if the user is offline.

If the user has not specified their skype username, it displays nothing.

Dependencies: profile.module must be installed and enabled.

An optional extra little piece of javascript checks to see if the user viewing the profile page has skype installed and displays a friendly link explaining what it is if they don't. Click through to skype.com for what the alternate message on the skype.com site looks like and says.

Usage

Send private message snippet

PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Description

This php snippet inserts the SEND A PRIVATE MESSAGE link

Dependencies: privatemsg.module must be installed and enabled.

ARCHIVE: Handling URL profile fields

PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Description

This php snippet displays custom User Profile URL fields. If the user has not specified any link, it displays nothing.

Dependencies: profile.module

Usage

  • Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file
  • Change the Custom profile URL field name. In the example that is currently $urlfieldname='profile_weburl' (Tip: go to administer -->> settings -->> profile and in the second column it will give you the name of the URL field.)
  • If you are using this snippet more than once in the same user_profile.tpl.php file add a number to the end of the $urlfieldname each time you copy the snippet. e.g. $fieldname1, $fieldname2, $fieldname3 etc.
  • Change the div class names or the link prefix text to suit.


<?php
 $urlfieldname='profile_weburl' ;
?>

<?php
 if($account->$urlfieldname):
?>

Pages

Subscribe with RSS Subscribe to RSS - Drupal 4.5.x or older