Showing the link to a specific file
To show the link for the file whose ID is 2, embed the following shortcode on a page or post:
[groups_file_link file_id="2"]
The file IDs are shown on the Groups > Files admin section along with each file that has been uploaded from there.
Showing links to all files for registered users
File links can be listed by group. To conveniently provide download links for the registered users, embed the following shortcode on a page or post:
[groups_file_link group="Registered"]
Besides Registered, any name or ID of an existing group can be used.
Showing links to all files for users in a group
Assuming you have created a group named Premium, the list of links to all files assigned to that group is shown using the following shortcode embedded on a page or post:
[groups_file_link group="Premium"]
Using additional attributes
Additional attributes can be specified including attributes for the a tag.
For example, if you want to show the file descriptions along with their links:
[groups_file_link group="Premium" description="yes" class="file-link"]
If you want to apply the file-link
class to the links, you can use:
[groups_file_link group="Premium" class="file-link"]
Example page for registered users
A downloads page that provides files to registered users can be built using Groups and Groups File Access shortcodes. Here is an example that will remind members to log in before they can access the files, or offer others to create a new account.
[groups_non_member group="Registered"]
<h2>Please log in</h2>
You must be a registered member to access the files available for download.
Please log in to access the files.
[groups_login]
[/groups_non_member]
[groups_member group="Registered"]
<h2>Downloads:</h2>
[groups_file_link group="Registered" description="yes"]
[groups_logout]
[/groups_member]
Embedding a PDF Viewer
It is possible to use the session access feature built into Groups File Access to provide links to protected files that can be used with tools that allow to embed PDF files on a page.
Download GFA PDF Viewer and use it with PDF Viewer. When both plugins are activated, you can simply indicate the file ID using this shortcode to display the file:
[gfapdfviewer file_id="1" session_access="yes"]
Embedding Audio
Audio files can be embedded using the <audio>
element using the [groups_file_url]
shortcode to indicate the source. Assuming that there is an audio file, for example a piece of music in the mp3 format, whose file id is 4, the following code can be used while editing a page or post in Text mode:
<audio controls src='[groups_file_url file_id="4"]'>
</audio>
Embedding Video
Using the <video>
element, protected videos can be embedded with Groups File Access indicating the source with the [groups_file_url]
shortcode. Similar to the example above, edit a page in Text mode and paste the following code. The example assumes that there is a valid video file whose id is 5:
<video controls src='[groups_file_url file_id="5"]'>
</video>
Here is an extended example which assumes that members of the Premium group will be able to access the embedded audio and video:
[groups_member group="Premium"] <video controls src='[groups_file_url file_id="5"]'> </video> [/groups_member] [groups_non_member group="Premium"] Please log in to access protected media. [groups_login] [/groups_non_member]
Processing shortcodes in specific cases
Sometimes a shortcode will not be processed and it is necessary to wrap a content section using the [groups_file_access_process]
pseudo-shortcode. This is especially the case when a shortcode is used to provide the attribute of another shortcode.
[groups_file_access_process]
[another_shortcode attribute="[groups_file_url file_id="11" session_access="yes"]"]
[/groups_file_access_process]