How to Integrate a Custom Module with Frontend User in CMS Made Simple?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Ariel19
New Member
New Member
Posts: 1
Joined: Thu Jun 05, 2025 3:09 am

How to Integrate a Custom Module with Frontend User in CMS Made Simple?

Post by Ariel19 »

Hi everyone,
I am developing a custom module in CMS Made Simple (latest version) and would like to integrate it with the Frontend User system, specifically to display data for each user individually when they log in.
Can anyone share a tutorial or specific example on how to do this?
Thanks a lot!
Ariel Brwon Retro Bowl
User avatar
airelibre
Dev Team Member
Dev Team Member
Posts: 100
Joined: Tue Dec 01, 2009 3:42 pm

Re: How to Integrate a Custom Module with Frontend User in CMS Made Simple?

Post by airelibre »

Hello,

As FrontEndUsers is no longer maintained, you should now use MAMS (Members Access Made Simple) to achieve this.

In a module, you can use several MAMS methods to check if a user is logged in, the groups he/she belongs to, ...

Example :

Code: Select all

// Get the module
$mams = \cms_utils::get_module('MAMS');

// Check is a user is logged in and get the user ID
$userId = $mams->LoggedInId();

// Get the groups
$groups = $mams->GetMemberGroups();
Check the class MAMSManipulator in modules/MAMS/lib/class.MAMSManipulator.php to get all the methods available, and use it directly with the MAMS module instance ($mams on the upper code).

Have fun!
User avatar
magallo
Dev Team Member
Dev Team Member
Posts: 123
Joined: Thu Mar 24, 2011 12:37 am

Re: How to Integrate a Custom Module with Frontend User in CMS Made Simple?

Post by magallo »

To integrate your custom module with the MAMS in CMS Made Simple and display data for each user individually when they log in, follow these steps:

MAMS Integration:
Ensure you have the MAMS module installed and configured in your CMSMS installation.

User Authentication:
You can use MAMS::get_current_user() to get the current user object.

Create a Frontend Action:
In your custom module, create an action file (e.g., action.default.php) to handle the frontend display.
Use this action to query and display user-specific data.

Display User Data:
Create a Smarty template (e.g., default.tpl) to display the user-specific data.
Assign the queried data to the template and display it.

Here's a basic example of how your action.default.php might look:

Code: Select all

<?php
if (!defined('CMS_VERSION')) exit;

$mams = MAMS::get_instance();
$user = $mams->get_current_user();

if ($user) {
    // User is logged in, fetch their data
    $user_id = $user->id;
    $query = new YourCustomQuery(array('user_id' => $user_id));
    $user_data = $query->GetMatches();

    $tpl = $smarty->CreateTemplate($this->GetTemplateResource('default.tpl'), null, null, $smarty);
    $tpl->assign('user_data', $user_data);
    $tpl->display();
} else {
    // User is not logged in, handle accordingly
    echo "Please log in to view your data.";
}
Remember to create the corresponding Smarty template (default.tpl) to display the user data.
Magal Hezi
Pixel Solutions, Technology Partners
magal@pixelsolutions.biz | pixelsolutions.biz

Image
Post Reply

Return to “Modules/Add-Ons”