Page 1 of 1

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

Posted: Thu Jun 05, 2025 3:11 am
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!

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

Posted: Fri Jun 06, 2025 6:30 am
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!

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

Posted: Thu Sep 04, 2025 10:12 am
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.