NP_Profile.php

This plugin is used to extend the profile of site members. Custom fields can be added to the member profile page, and the values of the fields can be displayed in various skin parts and templates. A number of custom fields are included in the default installation. The site administrator can add new fields and modify existing field attributes from a plugin admin page.

Note: Full details on the use and configuration of this plugin are available in the help file distributed with the plugin and available at the link below. This page is an incomplete subset of this help file and is not fully up-to-date.

General Plugin info
Current Version: 2.27
Download: v2.27
Code: n/a
Demo: n/a
Forum Thread: forum

Requirements

Requires NucleusCMS v 3.22+. To use file fields, the NucleusCMS media directory must be writable by the web server user (777).

Upgrading

Version 2 has changed much from version 1, including additional database tables and plugin options. This requires that version 1 be uninstalled before version 2 can be installed. Please follow this procedure to upgrade to version 2 from version 1, or from the version 2 beta to version 2.01+. Those upgrading from the beta should be sure that the plugin options regarding deletion of db tables on uninstall are set to no (the default).

  • Upgrading from version 2.01 to 2.02 or higher also requires you follow this procedure, but step 2 can be skipped.
  • Upgrading from 2.02 or higher to 2.0x does not require a special procedure. Simply copy the new files over the old files.
  • Upgrading from version 2.0x to 2.1 or higher requires you follow this procedure, but step 2 can be skipped.
  • Upgrading from version 2.1x to 2.1x does not require a special procedure.
  • Upgrading from version 2.0x or 2.1x to 2.20 or higher requires you follow this procedure, but step 2 can be skipped.
  • Upgrading from version 2.2x to 2.2x does not require a special procedure.
  1. Backup your database.
  2. Make a copy of your existing nucleus/plugins/NP_Profile.php file to a safe place. You will need this if you wish to revert later and to help you migrate your custom field settings to the version 2 database storage.
  3. If you are currently running v 1.2 or v 1.3, you must edit your existing nucleus/plugins/NP_Profile.php file to delete the following lines:
    function unInstall() {
          sql_query("DROP TABLE ". sql_table(plugin_profile));
       }

    If you fail to do this step, you will lose your existing member profile data and hope you did step 1 (backed up your database).

  4. Uninstall the NP_Profile plugin using the Nucleus Admin GUI.
  5. Install the new NP_Profile version as described below.

Installing

  1. Download and extract the zip file. Copy the NP_Profile.php file and the profile directory to the nucleus/plugins directory.
  2. Use the Nucleus Admin GUI to install the NP_Profile plugin into Nucleus. Be sure to click the 'Update subscription list' button after installation.
  3. You will need to edit and save the plugin options before using the plugin. The options are described below.

How to use the plugin

See the help file linked above (and distributed with the plugin) for the most up-to-date details of its use.

Skin and Template variables are available to display member profile fields in skins and templates as described below. In order for users to be able to update their profiles, the profile form must be created using skinvars in the Member Details part of the skin being used. An example of a Members Detail skin part using the default fields can be found in the NP_Profile admin area once the plugin is installed. A logged-in user can go to his/her member page to make changes to the profile. The Site administrator(s) can add/modify fields for use with this plugin from the NP_Profile admin area. He can also set defaults for the defined field types. See the help file for more detail.

Plugin Options

  • Show Admin Area in quick menu : Whether the Profile admin area should be shown in the Quick Menu area. yes or no. (yes)
  • Delete Profile user data table on uninstall? : Whether the database table containing your user data should be deleted on an uninstall. This should be set to 'yes' only when permanently removing NP_Profile. yes or no. (no)
  • Delete NP_Profile field definition tables on uninstall? : Whether the database tables containing your field definitions and type default data should be deleted on an uninstall. This should be set to 'yes' only when permanently removing NP_Profile, or when reverting back to version 1. yes or no. (no)
  • HTML tag or string to be placed before required field label : This is a string to be displayed before the label of a required field on the member input form. Can contain html. Text. (<i>)
  • HTML tag or string to be placed after required field label : This is a string to be displayed after the label of a required field on the member input form. Can contain html. Text. (*</i>)
  • URL to image to be used when none available : Valid URL to a file to be shown when no file is found when displaying a field of type file. Text. (url to default.jpg in your nucleus/plugins/profile directory)
  • To whom should we show email addresses? : User to whom we should show email addresses. All Users, Members Only, or Nobody. (Members Only)
  • Minimum Length in characters of a user password. : Check new user passwords for a minimum length. Integer. 0 disables length check. (0)
  • Password Complexity Check. : Check new user passwords for complexity. Complexity is determined by number of character types present. Types are a-z, A-Z, 0-9, punctuation. Off disables complexity check check. (Off)

SkinVars

The Profile skin variable is valid in the following skin types: 'member','archive','archivelist','item','index','template'. When a member is viewing his own member page, the fields are displayed as form input fields to allow the member to update his own profile.

It has the general form of

<%Profile(fieldname,special,showas,memberid)%> where

fieldname

The name of the field to display. By default, the valid values are nick, realname, mail, notes, url, privacylevel, msn, sex, birthdate, avatar, location, hobbies, secret, icq, favoritesite, bio, resume. The ones in bold are Nucleus member fields and represent data kept by the Nucleus Core. More details about these special Nucleus fields will be given later. It can also be one of a number of special values such as startform, endform, password, or status, as described later.

special

One of label or show as described below (can be left blank, the default behavior):

  • label - Valid for all fields. Shows the label for the named field..
  • show - Valid for all fields. Directs NP_Profile to display the field value in all cases (so wont show input field to member on his own page, so useful to show fields outside of member form). Will be formatted according to showas type, where applicable.

showas

One of image, link, or raw, as described below (can be left blank, the default behavior):

  • image - Valid for fields of type file. Shows the file as an image for the named field. Default for file type.
  • link - Valid for fields of type file, url, mail, list. Shows value of named field as a link. Default for url and mail types.
  • raw - Valid for fields of type file, url, mail, list, textarea. Shows raw value of named field with no html tags. File fields show as a raw URL. Default for list types.

memberid

The member id (number), or member name (login name) of the member who's profile field you wish to display. This is needed when NP_Profile cannot determine which member's info to display, such as on an index skin, or when you want a specific member's profile field displayed. The special value of '%ME%' can be used to show the logged on user his own data (say to display the logged on user's avatar next to the logout link in the sidebar).

Examples

Some usage examples are given here:

  • <%Profile(realname)%> will, on a member page, display the real name of the member whose page is being viewed. On an item page or in a template (see TemplateVar below) will show the real name of the item's author. On other skin types, it will display nothing.
  • <%Profile(realname, , ,2)%> will display the real name of member 2 on all skin types.
  • <%Profile(avatar)%> will display the input field for an avatar file.
  • <%Profile(avatar,show,image)%> will, on a member page, display the avatar, as an image, of the member whose page is being viewed. On an item page or in a template (see TemplateVar below) will show the avatar, as an image, of the item's author. On other skin types, it will display nothing.
  • <%Profile(avatar,show,image,jsmith)%> will display the avatar, as an image, of member jsmith on all pages.
  • <%Profile(bio,,raw)%> will show the contents of the bio field as regular text when not being edited.
  • <%Profile(password)%> will show a change password form only if a member is viewing his own member page. Otherwise, it displays nothing.
  • <%Profile(startform)%> will add the html needed to start an input form for members, but only if a member is viewing his own member page. Otherwise, it displays nothing. Must be used on Member Details skin part if members will be allowed to edit their own profiles.
  • <%Profile(endform)%> will add the html needed to end an input form for members, but only if a member is viewing his own member page. Otherwise, it displays nothing. Must be used on Member Details skin part if members will be allowed to edit their own profiles.
  • <%Profile(editlink)%> will add the html needed to display a link to the profile edit form, but only if a member is viewing his own member page. Otherwise, it displays nothing. Should be used on Member Details skin part if members will be allowed to edit their own profiles.

For some ideas see the Tips and Tricks section below.

TemplateVars

The skinvars described above can be used in the Item Body part of any template. However, the special types of password, startform, endform, editlink, and status, are not available.

Field Names

The values of the fieldname parameter of the SkinVar can be one of three main types – Special, Nucleus, Custom. Each of these type is described here.

Special

These fieldname values are only valid on the Member Details skin part and only when a member is viewing his own member page. These are what allow the member to update his own profile or change his own password.

  • startform is used on the Member Details skin part before any other calls to the <%Profile%> skinvar. It sets up the start of the member input form.
  • endform is used on the Member Details skin part after all calls to the <%Profile(fieldname)%> skinvar. It sets up the end of the member input form, including the submit button.
  • password is used on the Member Details skin part before, generally outside of the <%Profile(startform)%>…<%Profile(endform)%> block. It sets up the entire of the change password form.
  • status can be used to display the status of a update submit on the member input form.
  • editlink is used on the Member Details skin part to create a link to the profile edit form. Link only visible to members when viewing own profile.
  • editprofile is used on the Member Details skin part to create a link to the profile edit page. Link only visible to members when viewing own profile. Use in place of editlink to use new editprofile page of v.2.1.
  • submitbutton is used on the Member Details skin part to add an additional submit button to the form.

Nucleus

These fieldname values are fields maintained by the Nucleus Core and represent data in the standard member profile. They should not be modified, apart from their required, enabled, or field size status.

  • nick is the username the member uses to login.
  • realname is the real name of the member.
  • url is the home url of the member.
  • mail is the email address of the member.
  • notes is the notes field of the member.

Custom

These fieldname values are fields maintained by the NP_Profile plugin. The fields listed here are included as default with the plugin, but the site administrator can add more and modify these as desired.

  • privacylevel is the member's preference for who can see his profile. radio. (All Users, Members Only, Friends Only)
  • msn is the msn username of the member. text.
  • sex is the gender of the member. radio. (male or female).
  • birthdate is the birth date of the member. date.
  • avatar is the avatar of the member. file.
  • location is the location of the member. text.
  • hobbies are the hobbies of the member. text.
  • secret is the secret of the member. password. (never displayed, minimal use)
  • icq is the icq number of the member. number.
  • favoritesite is the favorite web site of the member. url.
  • bio is biographical info of the member. textarea.
  • resume is a link to the resume of the member. url.

Other fields can be added from the Plugin Admin area as described later. All fields must be of one of the types described in the next section.

Field Types

All fields must be of a type known to NP_Profile. The field type determines how the values of the field are handled and displayed. Currently, NP_Profile supports these field types.

  • text is a text field, usually used to store strings and limited to about 255 characters.
  • textarea is a text input area which can store longer text fields including formatting like new line. It is usually used for descriptive fields, like biographical information.
  • date is a date field and supports formatting using the format strings D-M-Y, M-D-Y, Y-M-D, Y-D-M, where D and M are 2 digits and Y is four digits. More formatting options available in 2.12. See help file for details.
  • file is a file stored in the Nucleus media directory. By default, only image files of type jpg, gif, and png are permitted, but any extentions can be allowed. By default only small files (< 50KB and smaller than 64×64 pixels) are permitted, but these size limits are configurable on a field by field basis.
  • list is a checkbox menu. Multiple values permitted. The options must be specified in the field definition as described in the Plugin manangement section.
  • number is a number field.
  • mail is an email address field. It must contain a valid email address.
  • url is an URL field. It requires a valid URL string and is displayed as a link
  • password is a password field. Its contents are never displayed, but could be used by another program, or the administator to validate a user, i.e. What's the name of your first school?.
  • dropdown is a dropdown menu. The options must be specified in the field definition as described in the Plugin manangement section.
  • radio is a radio menu. The options must be specified in the field definition as described in the Plugin manangement section.

Tips and Tricks

This plugin is very configurable and customizable, so not all uses are fully documented here. Feel free to experiment and share things that work with other users at the support forum thread. Here are a few ideas that might get your imagination started:

  • In your Item Pages skin part, put the author avatar and bio at the end of the page like this:(Could also go in the Item Body field of your item template)
<div class="authorbio">
<%Profile(avatar,show,image)%><%Profile(realname)%> &amp;mdash; <%Profile(bio,,raw)%>
</div>
  • In your index template, Item Body field, insert this to display the item author's avatar next to each item title:
<%Profile(avatar,show,image)%>
  • Create a file type field called vitae and permit pdf files. Now the user can upload his resume as a PDF file, and you can display a link to it on the Member Page like this: (or in templates, or in Item Pages skins)
<%Profile(vitae,show,link)%>
  • Using the same field, you want your resume link in the sidebar of all pages, add this to your sidebar:
<%Profile(vitae,show,link,yourname)%>
  • You want some profile fields only visible to logged-in members, use the <%if(loggedin)%> skinvar like this:
...public profile fields displayed here...
<%if(loggedin)%>
   ...private profile fields displayed here...
<%endif%>

Support and Bug Reports

Please report bugs and request support at the forum thread.

  • Textarea fields limited to 256 characters (Thanks TwistedLogic). Fixed as of 2.02 with max length of textarea now about 3500 characters.
  • Textarea fields do not maintain newlines (Thanks TwistedLogic). Fixed as of 2.02.
  • When field names are changed, member data not moved to new field name. Fixed as of 2.02.
  • When member deleted from Nucleus, his profile data is not deleted. Fixed as of 2.02.
  • When field is deleted, member data for that field not deleted. Fixed as of 2.02, and made delete of field a two-step process.
  • Generated links not XHTML compliant. (Thanks, bakaelite). Fixed as of version 2.03.
  • File permissions of uploaded files not explicitly set. (Thanks, wessite). Fixed as of 2.04.
  • Last two characters of textareas with less than 250 characters were being dropped. Fixed as of 2.04.
  • getAvatar() method missing URL to media dir. Thanks Shi. Fixed as of 2.14

History

  • v2.27 – 24th release of version 2 adds the following to 2.26
    • enhance memberlist feature with special memberlevel field type for sorting member list by level/points according to NP_MemberLevel
    • make NOT blog option to list all members not on given blog team, i.e !blogname
  • v2.26 – 23rd release of version 2 adds the following to 2.25
    • add resizeimage option to field of type file (images only) to automagically crop and resize images to fit field width/height.
  • v2.25 – 22nd release of version 2 adds the following to 2.24.01
    • add myprofile special field value to allow links to current member's profile or editprofile page from any page in the skin
  • v2.24 – 21st release of version 2 adds the following to 2.23.01
    • add doIf() method to allow using profile fields as conditionals.
    • add regfieldlist template type to allow other field lists to be used for registrations other than at createaccount.php file
    • improvements to memberlist
  • v2.23.01 – fix release of v 2.23
    • fix big where not normalizing forder and fpublic as integers causing mysql errors in certain situations
  • v2.23 – 20th release of version 2 adds the following to v 2.22.02
    • add API events for other plugins to add data variables to memberlist templates
  • v2.22.02 – 21th release of version 2 adds following to version 2.22.01
    • fix: fix errors in how lastupdated field stored.
  • v2.22.01 – 20th release of version 2 adds following to version 2.22
    • fix: fix errors in init() method when installing a fresh install.
  • v2.22 – 19th release of version 2 adds following to version 2.21
    • fix: logout after updating profile in certain circumstances (thanks wessite)
    • add: enhance memberlist to allow sorting by memberid (can use to show newest members)
    • add: enhance memberlist to all displaying only members on given blog team
  • v2.21 –18th Release of version 2 adds the following to version 2.20
    • fix: add plugin_profile_templates table to getTableList() method for backup
    • fix: double form open code on editprofile page
    • fix: formatting near top of editprofile page
    • add: PostProfileUpdate event for wessite (allows external plugin to subscribe to perform actions each time profile is updated by user)
    • add: editprofileheader config value to allow custom text to be displayed above the form on the editprofile page. (thanks pheser)
  • v2.20 – 17th release of version 2 requires upgrade procedure (uninstall/reinstall)]
    • keep lastUpdated field (date) - thanks david_again
    • Make skinvar for memberlist using template to call in different fields from profile - thanks pheser
    • Add memberlistpager skinvar for paging memberlist.
    • rename fvalidate column to fformatnull.
    • caching all profile values for a given member to lessen number of db queries per page.

* caching brought the number of queries for my test member page, displaying 18 profile fields from 233 queries to 19 queries

  • v2.19.01 – 16th Release of version 2 adds the following to version 2.19
    • fix headers already sent errors when user registering from createaccount.php in version 3.3x
    • add tab on admin page for sample createaccount.php file for adding Profile fields to registration.
  • v2.19: 09-19-2007 - 15th release of version 2 adds the following to 2.18 version
    • modify PostRegister event and doAction method to recognize more generic registration methods beyond creataccount.html (testing for NP_NewAccount)
    • modify output of radio fields to use labels for xhtml compliance
    • some syntax improvement to help.html for xhtml compliance
  • v2.18: 07-09-2007 - 14th release of version 2 adds the following to 2.17 version
    • fix the form on admin area member page
    • now can work in all skin types including error and search
    • use $CONF['ActionURL'] to set form action url
    • adds closeform to special field types, and moves all hidden fields to the startform special field.
    • fix bug on entry form where date fields displaying extra input fields when date value is blank.
  • v2.17: 05-22-2007 - 13th release of version 2 adds the following to 2.16 version
    • add NP_Profile fields to Member Settings page of the admin area.
    • add PostRegister event so NP_Profile fields can be added to member registration form (in createaccount.html).
  • v2.16: 04-27-2007 - 12th release of version 2 adds the following to 2.15 version
    • allow custom formatting of core nucleus member fields (mail, url, nick, realname, notes)
    • add format option to handle case where value is null (ie show this if value is null).
    • fix bug where you couldn't blank out a previously entered date field.
    • add option for deny message when user can't view email address
    • add formatting options to mail type to allow custom formatting of actual address. 4 new format vars for mail types: %ADDRESS% (full address), %USERNAME% (part of address to left of @), %TLD% (Top-Level Domain, part right of last .), and %SITENAME% (the middle part of the address, after the @ and before the last .)
    • add formatting option to mail type to allow customized @ and . replacements in mail address. %ADDRESS(R)%. see help for format.
    • add ticket functions to comply with nucleuscms v3.3 JP
  • Version 2.15: 04-27-2007 - 11th release of version 2 adds the following to 2.14 version
    • allow for use on custom skinparts (or at least doesn't forbid its use)
    • allow longer, textarea fields (config using file size field in field/type definition)
    • allow param4 as %CAT%. matches username to category desc
    • allow param4 as %BLOG%. matches username to blog shortname
    • fix bug in textarea fields where space at begin or end of chunk are lost.
    • when using custom format, nothing is displayed if requested value is null.
  • Version 2.14: 04-12-2007 - 10th release of version 2 adds the following to 2.13 version
    • fix getAvatar() method. Bad URLs being created.
  • Version 2.13: 03-23-2007 - 9th release of version 2 adds the following to 2.12 version
    • more fixes to bug in redirect for some fancy url schemes when using editlink
    • adds charset info to editprofile.php page (thanks, Shi)
    • adds %VALUE%, %FIELD%, %MEMBER%, %ID% variables to format.
    • permits site admins to edit all user profiles, except passwords. (thanks, Shi)
  • Version 2.12: 03-07-2007 - 8th release of version 2 adds the following to 2.11 version
    • fixes bug in redirect for some fancy url schemes when using editlink.
    • adds date() like formatting to date fields.
    • splits date input into three fields, for day, month, and year.
  • Version 2.11: 02-21-2007 - 7th release of version 2 adds the following to the 2.1 version
    • adds format option for fields of most types. Allows custom formatted links, etc. See docs.
    • fixes bug for mysql < 4.1
    • fixes bug in getAvatar() method for case where no avatar indicated
    • fixes bug in redirect after profile update for certain php environments.
  • Version 2.1: 01-16-2007 - 6th release of version 2 adds the following to the 2.05 version
    • adds knowledge of NP_Friends with privacylevel concept.
    • adds an editprofile page for editing profiles off the member details skin part.
    • Adds to special field types, submitbutton and editprofile.
    • Adds some field configuration settings:
      • Default (set the default value of a choice field),
      • Public (set whether field is viewable to all users despite privacylevel setting)
    • Adds getAvatar() method to make it easier for other plugins to retrieve the avatar
    • Adds ability to get the current logged in member's profile data using %ME% for fourth parameter of skinvar
  • Version 2.05: 12-01-2006 - Fifth release of version 2 adds the following to the 2.04 version
    • Adds support for comment template variable.
  • Version 2.04: 11-21-2006 - Fourth release of version 2 adds the following to the 2.03 version
    • Forces chmod of uploaded files to 644. Thanks, wessite!
    • Allows additional protocols for type url (set in Options field of field def). semi-colon separated list.
    • Allows textarea to allow tags as decided in field def (Options field).string of angle-braketed tags to allow. Like <b><img>.
    • fixes bug in how short textarea values are handled in editing (was losing last two characters of field).
  • Version 2.03: 11-14-2006 - 3rd release of version 2 adds the collowing to the 2.02 version
    • Generated links now XHTML compliant (use title attribute instead of alt)
  • Version 2.02: 10-27-2006 - 2nd release of version 2 adds the following to the 2.01 version
    • Allows line breaks in textarea fields (not in nucleus notes field).
    • Allows textareas greater than 256 characters (adds torder field to plugin_profile table, plus other code changes). max size is 3500 characters, rest truncated.
    • Deletes member's data when member deleted.
    • Deletes values from plugin_profile for deleted fields.
    • Changes name of field for data in plugin_profile when field is renamed.
    • Explicitly create tables with MyISAM engine for better performance, instead of the system's default engine. Converts existing tables to MyISAM if not already.
  • Version 2.01: 10-25-2006 - First public release of version 2, includes these and other improvements
    • improved the handling of files (cleaned code and added support for non-image extentions)
    • Internationalized the plugin (English only, so far, but hope to get translations for future versions)
    • Added a password validation function to check password length and complexity
    • Added support for list type (checkbox)
    • Added support for showas skinvar parameter to more field types, gives more display format options
    • Added support for show skinvar parameter for all field types (was just for file) to force display of data not form field
    • Limited display of the profile form to case where member requests it through a link (editlink)
    • Improved date formatting options
    • Improved redirection upon form submittal, including success messages.
  • Version 2.0.02b: 10-18-2006 - Beta release of version 2, includes these and other improvements
    • GUI-based field management
    • Bug fixes
    • Support for skin types beside member skin
    • Support for Template Var
  • v1.0a initial version
  • v1.1 fixed sql_table and supportsFeature missing problem

Plugin Review

NP_Profile version 2.19 works with Nucleus CMS version 3.31 - 2007-11-03 kg

profile.txt · Last modified: 2012/04/02 18:20 by ftruscot
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki