Skip to main content

Dynamically Changing API Response with Login User Information

This tutorial explains how to dynamically change API endpoint responses using login user information. We will change the display content of the news list according to the logged-in user, with the following configuration:

Add Company Name to Member Extension

Click [Member] -> [Member].

Image from Gyazo

Click [Advanced Member Settings].

Image from Gyazo

Click [Configure field settings for members].

Image from Gyazo

Configure as follows and click [Update].

Item nameCompany Name
SettingSelection Format
1::Company A
2::Company B

Image from Gyazo

Click the name of the test member for operation check on the Member List page. Image from Gyazo

On the member editing page, set the company name in the profile information tab. Image from Gyazo

Add Target Company to Content (news)

Click [Content Structure].
Image from Gyazo

Click on [news] from the content structure list. Image from Gyazo

On the content structure edit screen, set as follows and click [Update].

Parent itemNo selection
Item nameTarget
Item settingMultiple choice (checkbox)
1::Company A
2::Company B
3::Company C

Image from Gyazo

The added items will be displayed on the content editing screen, so check the target company name and update it. Image from Gyazo

Add custom processing to set login user information to filter query

Next, add custom processing to get login user information. Click [Operation] > [Custom function]. Image from Gyazo

Click [Add]. Image from Gyazo

Set as follows, and click [Add].

TitleAdd login user information to filter query
ProcessCode below
{if $smarty.session.super_flg ne 1}
{assign_member_detail var='mem' member_id=$smarty.session.member_id}
{assign var=request.filter value="ext_1 contains `$mem.company_id_key`"}

Image from Gyazo


For details on the notation of the filter parameter, see Using the filter query function.

Allow Filter Requests and Set Up Pre-processing for the Endpoint

Click on the API that has the endpoint to retrieve the list of news. Image from Gyazo

Click on [Update] for the endpoint that retrieves the list of news. Image from Gyazo

Enter ext_1 in the filter_request_allow_list parameter, and then click [Update]. Image from Gyazo

Next, click on [Pre-processing]. Image from Gyazo

Set the category to "Uncategorized" and select "Add login user information to filter query" from the list. Image from Gyazo

Verify the Operation

Finally, verify the operation. After logging in, check the news list page to confirm that the contents of the displayed list are filtered. Image from Gyazo


Note that the operation cannot be confirmed with Swagger UI, so please confirm it in a browser. Reference FAQ: How do I verify requests that cannot be verified with Swagger UI?


If you have any other questions, please contact us or check out Our Slack Community.