Home » Documentation > Introduction » Login Considerations

Login Considerations

The majority of web applications (although not all) will require some form user identification for security and authentication.

In DataFlex web applications, the level of required identification is specified through setting the “peLoginMode” property of the web app object to one of: lmLoginNone, lmLoginSupported or lmLoginRequired.

However WordPress has its own user login mechanism and it may well be that adding an extra layer of login on top of that would not be desirable (another user-name and password for users to remember, another hurdle to jump before they can get on with whatever they are there for).

For that reason a new property of the web app: pbUseWPLogin (Boolean – default: False) has been added.  If this is set to True, then it is the logged-in state of the user within WordPress which will determine whether they have access to the WebApp (whether an embedded app or embedded views), rather than that of the DataFlex framework.  If a login is required and the user is not logged in they will be prompted to do so in order to access the feature.

The boolean function InWordPress of the cWPWebApp class can be called to determine if the application is running within WordPress.

To support this, a collection of information from WordPress is available in the DataFlex program through calls to the WPInfo function of the web app object.  Get WPInfo of ghoWebApp “itemname” to var will return the desired value.

  • sWPTimeSent (Number – the number of seconds since the start of the UNIX epoch, to four decimal places on Windows; used to ensure uniqueness in the security hash)
  • bWPUserLoggedIn (Boolean – True if the user is logged into WordPress)
  • sDF4WP_Parameters (String – the entire contents of the “params” setting in the “shortcode” which invoked the web app or view)
  • sWPView (String – the object name of the view, if an embedded view)
  • sWPSiteAddress (String – the base URL of the WordPress site)
  • sWPLoginURL (String – the URL to use to login to the WordPress site)
  • sWPHomeURL (String – the URL of the site’s home page)

If the user is logged into WordPress, then the following items will contain information about them:

  • iWPUserID (Integer – the WordPress internal ID of the user)
  • iWPUserLevel (Integer – the WordPress “level” of the user – 10 is Administrator)
  • sWPDispName (String – the display name of the user)
  • sWPFirstName (String – the first name of the user)
  • sWPLastName (String – the last name of the user)
  • sWPUserLogin (String – the login of the user)
  • sWPUserEMail (String – the e-mail address of the user)
  • sWPUserURL (String – the user’s web site, if one has been supplied)
$info .= chr(31) . 'yourItemName=' . someWordPressFunction();

Take care with the syntax – PHP is unforgiving of errors and the entire site may stop working if you make an error such as leaving off the terminating semicolon.

The result of the WordPress function (or it could be a variable) will then be available in your DataFlex program through calling:

Get WPInfo of ghoWebApp "yourItemName" to var