Using CPF's in Newsletters

Post

Posted
Rating:
#5110 (In Topic #1153)
Avatar
Standard member
supertramp4 is in the usergroup ‘Well-settled’
Hi,

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
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Chris Graham)
#5111
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
{$CPF_VALUE,Some Custom Field}

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).
Online now: No Back to the top

Post

Posted
Rating:
#5124
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Try something like {$CPF_VALUE,20,{member_id}}.

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.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: Yes Back to the top

Post

Posted
Rating:
#5129
Avatar
Standard member
supertramp4 is in the usergroup ‘Well-settled’
Hi chris / joe

Adding the {member_id} works nicely
Thanks
Chris
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

Vaiva, Philip, cwdean, Chris Graham, babu, Salman, amit.nigam, John Connor

Forum statistics:
  • 1,361 topics, 5,911 posts, 7,290 members
  • Our newest member is advanceayurveda
Birthdays:
Back to Top