Jump to content

How push user's member group to cookie?

Featured Replies

Posted

Hi,

IPB currently sets a cookie which has the ips4_member_id stored, I would like to also set the member group? 

Does anyone know how I'd do this?

Thanks

Why do you wanna do this? 

  • Author

I want to use an ad platform which works behind their DNS, they dynamically intercept the request, edit and serve. I want to stop the serving of ads to a certain user group which they'd be able to lookup from a cookie.

Is the ad being placed using the IPS advertisement functionality? If so, use the group setting on the ad there instead.

  • Author

Hi Nathan, the ad system (Ezoic) sits entirely outside of my server and code. The code isn't touched at all. The original server request is intercepted.

Would they be able to pick up the group from a javascript variable in the html instead?

If you want to put the user's group into a cookie, you have a few things to consider.

1) You'd need to write a plugin to do this, as it doesn't happen out of the box. It's not difficult to do so, but it would be necessary.

2) Users can belong to multiple groups, so you'd want to set all of those groups and be sure your ad platform can read all of them. Whether that's a comma separated list or some other format though, you'd have to check with the ad platform.

 

  • Author
On 5/15/2018 at 7:54 PM, Nathan Explosion said:

Would they be able to pick up the group from a javascript variable in the html instead?

Good idea @Nathan Explosion, will check, hadn't thought to ask that.

On 5/15/2018 at 11:17 PM, bfarber said:

If you want to put the user's group into a cookie, you have a few things to consider.

1) You'd need to write a plugin to do this, as it doesn't happen out of the box. It's not difficult to do so, but it would be necessary.

2) Users can belong to multiple groups, so you'd want to set all of those groups and be sure your ad platform can read all of them. Whether that's a comma separated list or some other format though, you'd have to check with the ad platform.

 

Thanks @bfarber, seems like I've got a lot to learn then. Thought it might be as easy as adding a line of code to the existing method of setting the cookie.

  • 2 weeks later...
  • Author

Hi @Nathan Explosion I didn't think about this before, but a JS variable would work as I could use Google Tag Manager to create the cookie. Would this be an easier method and how would I go about this? Thank you

In a template to use just the primary group:

<script>
  var groupId = {expression="\IPS\Member::loggedIn()->member_group_id"};
</script>

or for all group ids (comma-separated):

<script>
  var groupIds = "{expression="implode( ',', \IPS\Member::loggedIn()->groups )"}";
</script>

 

  • Author

Perfect thank you

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.