/
Conditional Rules

Conditional Rules

The following smart tags can be used to conditional display certain elements to the user

Logged in/out

  • {ifloggedin}{/ifloggedin} : Will display the enclosed content only if the user is logged in as non-guest.

  • {ifloggedout}{/ifloggedout} : Will display the enclosed content only if the user is logged out or is loggedin as guest.

  • {ifloggedinas}{/ifloggedinas} : Will display the enclosed content only if you are logged in as (loginas) a different user.

  • {ifnotloggedinas}{/ifnotloggedinas} : Will display the enclosed content only if you are logged in as yourself and not as a different user.

Courses

  • {ifenrolpage}{/ifenrolpage} : Will only display the encclosed content if the user is on a course enrolment page.

  • {ifnotenrolpage}{/ifnotenrolpage} : Will only display the encclosed content if the user is not on a course enrolment page.

  • {ifenrolled}{/ifenrolled} : Will only display the enclosed content if the user is enrolled as a student in the current course. This tag ignores all other roles.

  • {ifnotenrolled}{/ifnotenrolled} : Will only display the enclosed content if the user is not enrolled as a student in the current course. This tag ignores all other roles.

  • {ifincourse}{/ifincourse} : Will only display the enclosed content if the user is in a course.

  • {ifnotincourse}{/ifnotincourse} : Will only display the enclosed content if the user is not in a course, such as the Frontpage, dashboard or site administration pages.

  • {ifinsection}{/ifinsection} : Will only display the enclosed content if the user is in a section of a course which is not the Frontpage.

  • {ifnotinsection}{/ifnotinsection} : Will only display the enclosed content if the user is not in a section of a course.

  • {ifingroup id|idnumber}{/ifingroup} : Will only display the content if the user is part of the specified course group ID or group ID number.

  • {ifnotingroup id|idnumber}{/ifnotingroup} : Will only display the content if the user is NOT part of the specified course group ID or group ID number.

  • {ifingrouping id|idnumber}{/ifingrouping} : Will only display the content if the user is part of the specified course grouping ID or grouping ID number.

  • {ifnotingrouping id|idnumber}{/ifnotingrouping} : Will only display the content if the user is NOT part of the specified course grouping ID or grouping ID number.

  • {ifvisible}{/ifvisible} : Will only display the content if the course visibility is set to Show.

  • {ifnotvisible}{/ifnotvisible} : Will only display the content if the course visibility is set to Hide.

  • {ifinactivity}{/ifinactivity} : Will only display the content only in course activities.

  • {ifnotinactivity}{/ifnotinactivity} : Will only display the content only when not in a course activity.

  • {ifactivitycompleted id}{/ifactivitycompleted} : Will only display the content if the activity module specified by the id (see the activity's URL id=value), has been completed. Requires that completion be enabled for the site, the course and configured in the specified activity. Note: Activity IDs change when you copy or restore a course. In such cases, you will need to manually edit and correct the IDs in the tags to reflect the new activity id numbers to restore their functionality.

  • {ifnotactivitycompleted id}{/ifnotactivitycompleted} : Will only display the content if the activity module specified by the id (see the activity's URL id=value), has NOT been completed. Requires that completion be enabled for the site, the course and configured in the specified activity. Note: Activity IDs change when you copy or restore a course. In such cases, you will need to manually edit and correct the IDs in the tags to reflect the new activity id numbers to restore their functionality.

Roles

  • {ifstudent}{/ifstudent} : Will display the enclosed content only if the user is logged in and enrolled in the course as a student (has no other roles).

  • {ifminstudent}{/ifminstudent} : Will display the enclosed content only if the user is logged in and enrolled in the course as a student (may have other roles).

  • {ifinstructor}{/ifinstructor} : Will display the enclosed content only if the user is logged in as an instructor in the current course. Note that the instructor has fewer permissions than the Lead Instructor.

  • {ifmininstructor}{/ifmininstructor} : Will display the enclosed content only if the user is logged in as an instructorr or above in the current course.

  • {ifleadinstructor}{/ifleadinstructor} : Will display the enclosed content only if the user is logged in as a lead instructor in the current course.

  • {ifminleadinstructor}{/ifminleadinstructor} : Will display the enclosed content only if the user is logged in as a lead instructor or above in the current course.

  • {ifcreator}{/ifcreator} : Will display the enclosed content only if the user is logged in as a course creator.

  • {ifmincreator}{/ifmincreator} : Will display the enclosed content only if the user is logged in as a course creator or above.

  • {ifsysadministrator}{/ifsysadministrator} : Will display the enclosed content only if the user is logged in as a System Administrator.

  • {ifcustomrole roleshortname}{/ifcustomrole} : Will display enclosed content only if the user has the custom role specified by its shortname within the current context.

  • {ifnotcustomrole roleshortname}{/ifnotcustomrole} : Will display enclosed content only if the user does not have the custom role specified by its shortname within the current context.

  • {ifincohort CohortID|idnumber}{/ifincohort} : Will display enclosed content only if user is a member of the specified cohort. You can specify the Cohort ID in your cohort settings or its ID number. Cohort ID can contain a combination of letters from a to z, A to Z, numbers 0 to 9 and underscores. It will not work if it contains spaces, dashes or other special characters.

  • {ifnotincohort CohortID|idnumber}{/ifnotincohort} : Will display enclosed content only if user is NOT a member of the specified cohort. You can specify the Cohort ID in your cohort settings or its ID number. Cohort ID can contain a combination of letters from a to z, A to Z, numbers 0 to 9 and underscores. It will not work if it contains spaces, dashes or other special characters.

  • {ifhasarolename roleshortname}{/ifhasarolename}: Will display enclosed content if the user has the specified role anywhere on the site. This conditional tag works with role shortnames, not role archtypes. It is not context sensitive.

Miscellanious

  • {ifhome}{/ifhome} : Will display the enclosed content only if the user is on the Home Frontpage.

  • {ifnothome}{/ifnothome} : Will not display the enclosed content if the user is on the Home Frontpage.

  • {ifdashboard}{/ifdashboard} : Will display the enclosed content only if the user is on the Dashboard.

  • {ifeditmode}{/ifeditmode} : Will display the enclosed content only if editing mode is turned on.

  • {ifprofile_field_shortname}{/ifprofile_field_shortname} : Will display the enclosed content if the custom user profile field is not blank/zero. Only visible custom profile fields are supported unless the Smart Tag ifprofilefiedonlyvisible setting is unchecked. Does not include support for core profile fields like the {ifprofile...} tags mentioned above.

  • {ifprofile shortname is "value"}{/ifprofile} : Will only display the enclosed content if the value of the specified user profile field matches the specified value.

  • {ifprofile shortname is ""}{/ifprofile} : Will only display the specified user profile field is empty. See note below.

  • {ifprofile shortname not "value"}{/ifprofile} : Will display the specified user profile field is not equal to the specified value.

  • {ifprofile shortname not ""}{/ifprofile} : Will display the specified user profile field is not empty. This is similar to the {ifprofile_field_shortname} tag but can't be nested. See note below.

  • {ifprofile shortname contains "value"}{/ifprofile} : Will only display the enclosed content if the contents of the user profile field is an exact match to the specified value. See note below.

  • {ifprofile shortname in "value"}{/ifprofile} : Will only display the enclosed content if the contents of the user profile field appears in the specified value. See note below.

Note: The shortname for {ifprofile shortname...} tags can be any custom profile fields, regardless of whether or not they are visible, as well as the core 'id', 'username', 'auth', 'idnumber', 'email', 'institution', 'department', 'city', 'country', 'timezone', or 'lang' core profile fields.

Conditionally display content (For Mobile app and Web services)

  • {ifmobile}{/ifmobile} : Will display content if accessed from a web service such as the mobile app.

  • {ifnotmobile}{/ifnotmobile} : Will display content if not accessed from a web service such as a web browser.

Related content

User Interface Elements
User Interface Elements
More like this
Course Fields
Course Fields
More like this
Smart Tags
Smart Tags
More like this
Restricting Access
Restricting Access
More like this
Course Category Fields
Course Category Fields
More like this
Determining when a User Last Logged In
Determining when a User Last Logged In
More like this