[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 fileshow
optional – defaults to “name”. Acceptable values are any ofname
,description
,count
,max_count
,remaining
,file_id
,size
(a human readable file size) andsizeb
(the size of the file in bytes)visibility
optional – defaults tocan_access
showing information only if the current user can access the file,always
will show information unconditionallyfilter
optional – defaults towp_filter_kses
determining the filter function that is applied to the information about to be shown. Ifnone
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 filevisibility
optional – defaults tocan_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 filegroup
– (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 groupsdescription
– defaults tono
, if set toyes
will show descriptions for each filedescription_filter
– defaults towp_filter_kses
and determines the filter function that is applied to descriptions before they are renderedorder
– useasc
for ascending order,desc
for descending orderorderby
– determines the sort order of files, allowed values arefile_id
,name
(default),description
,path
andmax_count
visibility
– defaults tocan_access
showing information only if the current user can access the file,always
will show information unconditionallyuser_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: description
, description_filter
, list_prefix
, list_suffix
, item_prefix
, item_suffix
, order
, orderby
, visibility
.
Additional attributes are accepted for the link’s a
tag. These are accesskey
, alt
, charset
, coords
, class
, dir
, hreflang
, id
, lang
, name
, rel
, rev
, shape
, style
, tabindex
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:
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
oralways
[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 togroups_file_url
, also allows to indicate one or more separated by comma:groups_can_access_file
,groups_can_not_access_file
,groups_file_access_service_key
,groups_file_info
,groups_file_link
andgroups_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]
.