No announcement yet.

[vB5] How To Setup Trial Memberships For New Members


  • [vB5] How To Setup Trial Memberships For New Members

    This is an update to the instructions that were originally created for vBulletin 3.

    These instructions will setup trial access to your forum such that new users must purchase a subscription within X days or they will lose their access. At the end of X days they will still be in the Registered Users usergroup which will qualify them for the promotion (demotion) into the "Expired Trial" usergroup.

    Note that we are using the default Registered Users usergroup as the trial usergroup since that is where new registrations go. Then we are demoting back to an "Expired Trial" usergroup at the end of X days.

    Create a new usergroup for expired trials
    Create the new group in your:

    Admin CP > Usergroups > Add New Usergroup

    When setting the permissions on the Add New Usergroup page, set all permissions to No except for the Can View Forum permission. This way the expired trial can still access the Paid Subscriptions page so they can purchase subscriber access after their trial has expired. In the meantime they won't be able to access anything else.

    You may wish to set specific forum permissions for this group:

    Admin CP > Channel Management > Channel Permissions
    Create a promotion (demotion) to expire the trials after X days
    Go to your:

    Admin CP > Usergroups > Promotions > Add New Promotion

    Use these settings, where X is the number of days after which trial accounts are expired:
    • Usergroup - Registered Users
    • Reputation Comparison Type - Greater or Equal to
    • Reputation Level - 0
    • Days Registered - X
    • Posts - 0
    • Promotion Strategy - Join Date
    • Promotion Type - Primary Usergroup
    • Move User to Usergroup - the group you created for expired trials

    Create a new group for Paid Subscribers
    Go to your:

    Admin CP > Usergroups > Add New Usergroup

    Set this group's permissions as appropriate for members who've taken out a Paid Subscription.

    You may wish to set specific forum permissions for this group:

    Admin CP > Forums & Moderators > Forum Permissions
    Create a subscription for subscribers to purchase

    Go to your:

    Admin CP > Paid Subscriptions > Add New Subscription

    Configure the subscription so it changes a user's primary group to the new group you created for subscribed users. Set whatever prices and lengths you want.
    Inform active trials of how long they have left
    You may wish to have an indicator on your site that tells a user how long they have left on their Trial Membership. The following code will give the Trial Member the date they joined and how many days they have left on their Trial Membership. If the user is then moved to the Expired Trial usergroup you created earlier, they will receive a message telling them that their Trial has expired.

    Rather than editing a template, I've chosen to use the Ad module within Site Builder to show these messages. This allows easier customisation using the module GUI rather than adding various conditional statements to the code.

    To add the messages, activate Site Builder and click on Edit Page. Then, drag an Ad Module to your page (I've chosen just below the Page Title module:


    Next, edit the module and create your first Ad. This will be for current Trial Members using the code below changing X for the number of days trial you setup in the Promotion previously:

    {vb:set daysleft, {vb:number {vb:math (({vb:raw user.joindate} + (X * 86400) - {vb:raw timenow}) / 86400)}}}  
                 <div align="center" style="color: red; background-color: white; border: 1px solid black; padding:2px">                 <br />                 You joined on {vb:date {vb:raw user.joindate}} so your trial access expires in {vb:var daysleft} days.  You can subscribe <a href="settings/subscriptions">here</a>.                 <br />             </div>
    Ensure you check the box for 'User belongs to usergroup' and select the Registered Users usergroup from the dropdown:


    Now create a second Ad - this will contain the message for those whose Trial has expired:

    <div align="left" style="color: red; background-color: white; border: 1px solid black; padding:2px">Your trial has expired. Please subscribe <a href="settings/subscriptions">here</a>.</div>
    This time, make sure the 'User belongs to usergroup' dropdown is set to your new Expired Users usergroup that you created earlier:


    Save the Ads, Module configuration and then save the page.

    Additional Information

    Both subscription expirations and promotions are handled by scheduled tasks:

    Admin CP > Scheduled Tasks > Scheduled Task Manager > User Promotions and Subscriptions

    By default, promotions run every hour while subscription expirations run once a day. So an expired trial can take up to one hour to change over, and an expired subscription can take up to one day. If you are testing your setup, then you can manually run these tasks using the Run Now button to see that the appropriate changes are being made.

    If a user's subscription expires then they will be dropped back to the expired group, either directly or by way of the Registered Users group and the demotion, depending on which group they were in when they purchased the subscription. This process can take time because of the tasks mentioned above.

    • Glenn Vergara
      Glenn Vergara commented
      Editing a comment
      This tutorial is very helpful including the expiration warning message.

      But if in case you want to display the warning on all pages of the site, you would need to add the same modules to every page. That is not maintainable though. What I did for one of my clients was a combination of API extension and template hook. I extended the fetchPageById function in the Page API and checked the usergroupid of the current session and calculate the days remaining if the user belongs to the free trial usergroup and added properties in the $page object to remember how many days left. Then I created a template hook at header_before_content hook location and passed page=page in the hook arguments and then in the template, I accessed the number of days from the $page object to display the message with number of days left. Here's how the template code would look like:
      {vb:set daysLeft, {vb:raw page.trial_days_remaining}}
      <vb:if condition=&quot;!empty($daysLeft)&quot;>
      	<div class=&quot;notices&quot;>
      		<vb:if condition=&quot;$daysLeft > 0&quot;>
      			<div class=&quot;notice&quot;>
      				You have <strong>{vb:raw daysLeft} day(s)</strong> remaining in your trial period. You can pay for subscription on <a href=&quot;settings/subscriptions&quot;>Subscriptions page</a>.
      		<vb:else />
      			<div class=&quot;error&quot;>
      				Your free trial period is over. You can pay for subscription on <a href=&quot;settings/subscriptions&quot;>Subscriptions page</a>.
      Note: If you see &quot; in the above code, replace it with double quote. This is a known bug in comments.

    • Trevor Hannant
      Trevor Hannant commented
      Editing a comment
      Tried to keep this to a simpler level based on queries received via the ticket system primarily, it was something that was wanted by users who don't have the same confidence in doing anything more significant.
    Posting comments is disabled.

Related Topics