Installing and Creating Templates
October 7, 2019
UltraMenu
February 21, 2023
Installing and Creating Templates
October 7, 2019
UltraMenu
February 21, 2023

Understanding the usersc folder

This page is part of our UserSpice Customization Guide.

The usersc folder serves a bunch of purposes that may not be obvious, so we'd like to take a few moments to lay out what it does and does not do.

It's the home for (most) addons

UserSpice defines addons as Language Packs, Widgets,  Plugins and Templates and all but Language Packs are stored in usersc.

Language packs are stored in users/lang

Widgets are in usersc/widgets

Plugins are in usersc/plugins

Templates are in usersc/templates

Editing Addons (Except Language)

Although addons are located in the usersc directory, they are not meant to be edited directly. If you want to modify one of the UserSpice addons, the proper way to do that is to copy the addon to another folder.  For instance, if you want to modify the standard template, you will copy the

usersc/templates/standard folder

to

usersc/templates/your_name_here

and edit away. This prevents our updates from breaking your modifications.  The same holds true for widgets and plugins.

Editing Language

If you don't like the way something is translated, you can override that in usersc.  Let's say that you want to override Italian (users/lang/it-IT.php).  You can create a file called usersc/lang/it-IT.php and override language keys in there.  The format looks like this.

<?php 
$lang = array_merge($lang, array(
    "DAT_SEARCH" 		=> "Your translation here",
    "DAT_FIRST" 		=> "Your translation here",
));

Overriding Core UserSpice Files

This used to be the most common use for usersc, but let's say that you want to completely override one of the "core" UserSpice php files that is located in the actual /users folder. Something like account.php.  You can copy

users/account.php

to

usersc/account.php

and your file will load instead of ours.   Please note, there is a whole other guide for customizing the dashboard using usersc.

Pro Tip

When you're poking around and considering customizing our files, do a search of the file for the term "usersc".  You will often find that there are optional files that can be created/edited in the usersc folder that will allow you to override/insert something in one of our files without forcing you to maintain a completely separate page.

Usersc Includes

The usersc/includes folder contains some things that you may  want to modify.

  1. analytics.php – Paste your Google analytics or other tracking code here and it will be loaded on every page automatically.
  2. custom_functions.php – Store your custom functions here and they will be available everywhere.
  3. database_navigation_hooks_dropdown.php – Allows you to put special codes like {{myCustom}} in menus to make them dynamic
  4. database_navigation_hooks.php – Same as above but for non-dropdown navigation links
  5. footer.php – Load code on the footer of every page
  6. head_tags.php – This is a perfect place to put something that needs to be at the top of every page.
  7. oauth_success_redirect.php – If you want to do something after someone logs in with oAuth, put that code here.
  8. security_headers.php – Set your php headers here
  9. user_agreement.php – Customize your user_agreement here.

 

Usersc Scripts

The usersc/scripts folder contains some things that you may  want to modify.

  1. additional_join_form_fields.php  – Allows you to add more form fields to the UserSpice join form.
  2. during_user_creation.php – This is where you process the form fields for #1 AND do any other things you want to do every time a new user is created.
  3. banned.php – Set a message what someone sees when they are banned from your site.
  4. custom_login_script_no_redir.php – This script runs every time someone logs in if you want to perform any tasks on login. Do not put redirects in here.
  5. custom_login_script.php – If you want to redirect people on login, you can do so here. This is a good place if you want different users to go different places.
  6. did_not_have_permission.php – This script runs every time someone tries to visit a page they do not have permission to visit.
  7. just_after_logout.php – Do some maintenance after someone visits users/logout.php.
  8. just_before_logout.php – Do some maintenance before someone is logged out after visiting users/logout.php.
  9. not_logged_in.php – This script is run when a user who is not logged in tries to visit a page that requires a logged in user.
  10. token_error.php – This is the error displayed if the form token check fails.