Formatting and pluggable functions (for developers)

The amr-users reporting plugin offers formatting functions for various fields.

Existing pre-defined special formatting

Many fields have pre-defined formatting.  the functions are prefixed with ausers_format_, followed by the ‘internal’ field name.  See the ‘nice names’ page to find the internal names.

For example for field ‘user_registered’, the function is called

ausers_format_user_registered

The function formats the field value as a ‘days ago’ field with a hover link showing the actual date and time.

See ausers-pluggable.php for examples

Your own formatting?

  • To create your own formatting, write your own little site specific plugin and create a formatting function with the right name structure for your field as above.
  • The plugin will check if a suitable function has been defined for a field it is formatting. If it does not exist, it will just output the value.
  • If you define your own function, the plugin will not use it’s functions
  • Special note for S2member users.  Due to way S2 member creates it’s user fields, when creating the formatting function name, please do the following:
    • any hyphens in the field name become underscores

Field Formatting Function Examples

  • ausers_format_avatar
  • ausers_format_user_registered
  • ausers_format_timestamp
  • ausers_format_user_settings_time (the last time the user changed their settings)

Formatting a Field with database table prefix built into name

  • strip the database prefix out of the field/function name
  • eg1: NOT
    • ausers_format_wp_capabilities_secondrole (), but rather:
    • ausers_format_capabilities_secondrole ()
  • eg2: NOT
    • ausers_format_wp_s2member_custom_fields-yourspecialfield (), but rather:
    • ausers_format_s2member_custom_fields_yourspecialfield ()

 

Other Pluggable Functions

amr_display_a_line ($line, $icols, $cols, $user, $ahtm);

the code that will display a user – see the code in ausers-pluggables.php

amr_display_a_page ($linessaved, $icols, $cols, $ahtm );

the code that will display a page of users inside the filters, headers etc – see the code in ausers-pluggables.php

amr_display_final_list ($linessaved, $icols, $cols,$page, $rowsperpage, $totalitems, $caption, $search, $ulist, $c, $filtercol, $sortedbynow);

the code that will display the full page of users  including the filters, headers etc – see the code in ausers-pluggables.php

In the Future?

  • Future versions of the plugin may have the ability to detect a field type (link, image) or for you to tell it what your special fields are (boolean values, image) so that it can format accordingly.
  • Stay tuned, maybe add a note in the feature requests part of the forum

This entry was posted in Uncategorized by admin. Bookmark the permalink.