Using CPF's in Newsletters
Posted
#4780
(In Topic #967)
Is it possible to include CPF fields when sending out a newsletter ?
if so could you give an example where either the CPF id=20, or CPF name = "TestCPF"
Thanks
Chris
Posted
Find the raw (unrendered) value of a custom profile field (pass in the ID number of a custom profile field, which can be found from the URL of where you to edit it – or pass in the human-readable name of the field – or pass in a field name from the f_members table). If you pass a second parameter, it will specify the member ID to use (if not passed, it will default to the current member). Note that Tempcode is not context-sensitive apart from the parameters passed into a template. The current member is whoever is logged in; if you are editing a template displaying a member's details (e.g. CNS_MEMBER_PROFILE_SCREEN) then you will need to explicitly specify the member ID in the second parameter using the member ID passed into that template (typically {MEMBER_ID}).
So you could either do:
- {$CPF_VALUE,20}
- {$CPF_VALUE,TestCPF}
If I may ask, what kind of CPF field would you want to add to a newsletter? The reason I ask is because, CPF values are pretty much user-specific. According to the docs, you also need to specify a member's ID if you don't want to return the CPF value of the current user. Since it's a newsletter, I'm not sure it's capable of grabbing the current user because there may not even be one.
Chris Graham can chime in on this as I'm not sure how the newsletter system works; but if you're trying to pull a CPF value from each recipient of the newsletter, can the system even correlate every recipient with each users CPF value?
If you're looking to pull a CPF value from a specific user, say yourself, then this is absolutely possible. Just include your user ID within {$CPF_VALUE}, like so: {$CPF_VALUE,20,2} (where 2 is would be the specific ID you wanted to pull the CPF value from).
Posted
This will only work for newsletters sent to members (via usergroups), not via newsletter signup.
The newsletter system substitutes in {member_id}. It's not actually Tempcode, but it works in an equivalent way. So this gets you the correct member IDs.
Then the e-mail's plain-text and HTML versions are generated… and for both of these cases Tempcode like CPF_VALUE should work properly.
Posted
Adding the {member_id} works nicely
Thanks
Chris
1 guest and 0 members have recently viewed this.
