Primary

Shortcodes

[groups_can_access_file]

Content enclosed by this shortcode will only be shown if the current user can access the file. The file is identified by the required file_id attribute.

Example: [groups_can_access_file file_id="3"] This is shown if the user can access the file.[/groups_can_access_file]

Attributes

  • file_id required – identifies the desired file

[groups_can_not_access_file]

Shows content enclosed by the shortcode only when the current user can not access the given file. Attributes and usage are the same as for the [groups_can_access_file]shortcode.

[groups_file_info]

This shortcode renders information about a file including the name, description, size, maximum number of allowed accesses per user, consumed and remaining number of accesses for the current user and the file id.

Example: [groups_file_info file_id="7" show="name"]

Attributes

  • file_id required – identifies the desired file
  • show optional – defaults to “name”. Acceptable values are any of namedescriptioncountmax_countremainingfile_idsize (a human readable file size) and sizeb (the size of the file in bytes)
  • visibility optional – defaults to can_access showing information only if the current user can access the file, always will show information unconditionally
  • filter optional – defaults to wp_filter_kses determining the filter function that is applied to the information about to be shown. If none or an empty value is provided, no filter function will be applied prior to rendering the information.

[groups_file_url]

This shortcode renders the URL that serves the file. An authorized user can visit the URL to download the file.

Example: [groups_file_url file_id="456"]

Attributes

  • file_id required – identifies the desired file
  • visibility optional – defaults to can_access showing information only if the current user can access the file, always will show information unconditionally

[groups_file_link]

This shortcode renders links to files. An authorized user can click on a link to download the related file.

Example: [groups_file_link file_id="78"]

Attributes

  • file_id – (required*) identifies the desired file
  • group – (required*) group name or ID – will list file links for the files that are related to the given group; a list of groups separated by comma is accepted and * can be used to indicate all groups
  • description – defaults to no, if set to yes will show descriptions for each file
  • description_filter – defaults to wp_filter_kses and determines the filter function that is applied to descriptions before they are rendered
  • order – use asc for ascending order, desc for descending order
  • orderby – determines the sort order of files, allowed values are file_idname (default), descriptionpath and max_count
  • visibility – defaults to can_access showing information only if the current user can access the file, always will show information unconditionally
  • user_id – defaults to the ID of the current user, an alternative user ID can be given

* Only one of file_id or group is required, both should not be provided.

These additional attributes can be used to customize the HTML used to render the list of files. By default, the list is rendered using <ul> and <li>.

  • list_prefix – defaults to <ul>
  • list_suffix – defaults to </ul>
  • item_prefix – defaults to <li>
  • item_suffix – defaults to </li>

The following attributes are only effective when used with the group attribute: descriptiondescription_filterlist_prefixlist_suffixitem_prefixitem_suffixorderorderbyvisibility.

Additional attributes are accepted for the link’s a tag. These are accesskeyaltcharsetcoordsclassdirhreflangidlangnamerelrevshapestyletabindex and target. Please refer to the HTML 4.01 Specification on the The A element for further information about these attributes.

Styling Example

The following example is created using the CSS rules below:

Example

The code below can be copied and pasted onto a page (using the Text editor mode, not the Visual editor mode):


<style type="text/css">
.downloads li {
list-style: none outside none;
padding: 16px;
margin-bottom: 8px;
}
.downloads div.name {
margin-bottom: 8px;
}
.downloads div.name a.groups-file-access {
background-color: #ddffbb;
background-image: url("http://www.itthinx.com/img/gfa-download.png");
background-position: right center;
background-repeat: no-repeat;
border-bottom: 4px solid #696;
border-radius: 4px;
box-shadow: 0 0 4px 0 #666;
color: #1a1a1a;
display: block;
font-size: 24px;
font-weight: bold;
padding: 16px 64px 16px 16px;
text-decoration: none;
}
.downloads div.description {
background-color: #cdc;
border-radius: 4px;
padding: 1em;
}
</style>

<div class="downloads">
[groups_file_link group="*" description="yes"]
</div>

[groups_file_visibility]

This shortcode allows to switch the default visibility setting for those shortcodes that provide a visibility attribute. The shortcode can be used multiple times on a page or post and will affect the shortcodes below it unless it is used again.

Example: [groups_file_visibility visibility="always"]

Attributes

  • visibility required – can_access or always

[groups_file_access_service_key]

This renders a key that can be used to request access to a file without the need to be logged in.

Users are assigned a Service Key that can be used to access a file by appending the service_key parameter to the file’s URL.

A user must be logged in for the shortcode to render any output.

The user that is related to the service key must belong to a group that is allowed to access the file. Only those files that are accessible to the user when logged in are also accessible using the user’s service key.

Example:

Assuming a file located at http://www.example.com?gfid=123 and a service key XXXXXXXXXX, the file can be accessed through the URL http://www.example.com?gfid=123&service_key=XXXXXXXXXX if the corresponding user belongs to a group that grants access to the file whose ID is 123.

[groups_file_access_process]

This is a pseudo-shortcode that allows to render shortcodes from Groups File Access in other shortcode attributes. This makes it possible to dynamically provide file URLs produced by Groups File Access and use them in other shortcodes.

Normally, WordPress does not render shortcodes when they are provided within attributes to other shortcodes but if you enclose a content section with [groups_file_access_process]...[/groups_file_access_process], then it will render selected shortcodes appropriately.

The most common use for this is to render [groups_file_url file_id="..."] once or more within the attribute of another shortcode.

Attributes

  • shortcodes (optional) – defaults to groups_file_url, also allows to indicate one or more separated by comma: groups_can_access_filegroups_can_not_access_filegroups_file_access_service_keygroups_file_infogroups_file_link and groups_file_url – representing the respective shortcodes provided by Groups File Access.

Examples

Process Shortcodes in Shortcode Attributes

This is an example of providing a dynamic file URL to a protected file with session access to another shortcode.

[groups_file_access_process]
[foobar src="[groups_file_url file_id="1" session_access="yes"]"]
[/groups_file_access_process]

Process Shortcodes where they are not recognized

In some cases, a shortcode is not processed and we must use our preprocessor to have the file URL created dynamically. This is the case when you use the <source> element within <audio> like in the following example:

[groups_file_access_process]
<audio controls>
<source src='[groups_file_url file_id="5"]'>
</audio>
[/groups_file_access_process]

The [groups_file_url] shortcode is processed correctly when it is provided within the src attribute of the <audio> element, but not when it is supplied as the src attribute of the <source> element as in this example. For cases like that, you can wrap the section with [groups_file_access_process].