<![CDATA[ SOLUTION: Using checkboxes to toggle extended profile fields - My Forums]]> https://forums.modx.com/thread/?thread=44097 <![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515942 http://forums.modx.com/thread/72924/register-checkboxes-and-usergroups]]> sottwell Dec 01, 2014, 05:24 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515942 <![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515933
e.g.
[] add personal detail to emails {snippet called "userDetail"}
[] show company ph number {snippet called "sACC"}
[] show voice code on alert emails]]>
bigben83 Dec 01, 2014, 02:37 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515933
<![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515932 bigben83 Dec 01, 2014, 02:26 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515932 <![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515931 sottwell Dec 01, 2014, 02:26 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515931 <![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515930
You can see where the error log is in the Manager, Manage -> Reports -> System Info, and the phpinfo() view link, in the Core section of the resulting display.
]]>
sottwell Dec 01, 2014, 02:15 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515930
<![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515929
php server log is showing the below
14.2.189.105 - - [01/Dec/2014:16:53:06 +1100] "GET /tick.html HTTP/1.1" 500 - "http://my.cloudalarms.net.au/manager/?a=element/chunk/update&id=30" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"

id=30 is another page, for some reason it is calling this and I cant see why...]]>
bigben83 Dec 01, 2014, 02:08 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515929
<![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515923
Why do you have a snippet named useExtended, and where does it get called on the page? That property in the Profile snippet just indicates whether to display the extended fields or not.
If true, will set as placeholders all extended fields as well.
Or is that just your name for the original checkbox_extended snippet?

You should gather those variables into an array, then use
return $modx->getChunk('myChunk', $vars);


http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/snippets/how-to-write-a-good-snippet#HowtoWriteaGoodSnippet-DonotincludeHTML]]>
sottwell Nov 30, 2014, 11:39 PM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515923
<![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515921
[[!Profile? &useExtended=`1`]] [[!UpdateProfile]]
[[!checkbox_extended? &container=`tick` &boxes=`checkbox1,checkbox2,checkbox3`]]

Then I created a snippet called "useExtended" and added the code from original post into it, [as below]. but for some reason it is throwing errors, and just showing a blank page.
//checkbox_extended
//Snippet to generate checkboxes that add/remove extended field values in a user's profile. This is used in conjunction with the Login Profile snippet.
<?php
//get your checkbox values - defined in your snippet call as &boxes=`checkbox1,checkbox2,checkbox3...`
$checkboxvalues = explode(",",$boxes,99);
 
//get extended field values from the user profile - use &container=`` in your snippet call to define the container name of the extended value(s). You'll find this in Manager > Security > Manage Users
$profile = $modx->user->getOne('Profile');
$extended = $profile->get('extended');
$extendedvalues = $extended[$container];
 
//compare the two and identify any matches. e.g. if checkbox1 == extendedfieldvalue1 then return a 'checked' result
for($x = 0; $x < count($checkboxvalues); $x++)
{
if(in_array($checkboxvalues[$x],$extendedvalues))
{
$selected = 'checked';
}else{
$selected = '';
}
//output the checkboxes - you can style it how you want here
$output.= '<div class="option"><input name="'.$container.'[]" number="" type="checkbox" value="'.$checkboxvalues[$x].'"'.$selected.'> '.$checkboxvalues[$x].'</input></div> ';
}
 
return $output;


Have in misinterpreted the instructions?
Using Platform: Modx Revo 2.3.2]]>
bigben83 Nov 30, 2014, 11:21 PM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-515921
<![CDATA[Re: SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-429868
I added
$user = $modx->getObject('modUser',$userId);
if (!$user) return '';
$profile = $user->getOne('Profile');

Adding this squelched the error associated with getOne('Profile'), but I am still unable to get the boxes to show on the page.

I am trying to use this in a wish list to remove the TV but stay on the page.
]]>
darwin Jul 13, 2012, 11:46 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-429868
<![CDATA[SOLUTION: Using checkboxes to toggle extended profile fields]]> https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-253601
Please note: I’ve used this in conjunction with the Login Profile snippet - it uses the Login Profileupdate submit button. Use the
[[!Profile? &useExtended=`1`]] [[!UpdateProfile]]
calls in the page.

//checkbox_extended
//Snippet to generate checkboxes that add/remove extended field values in a user's profile. This is used in conjunction with the Login Profile snippet.
<?php
//get your checkbox values - defined in your snippet call as &boxes=`checkbox1,checkbox2,checkbox3...`
$checkboxvalues = explode(",",$boxes,99);

//get extended field values from the user profile - use &container=`` in your snippet call to define the container name of the extended value(s). You'll find this in Manager > Security > Manage Users
$profile = $modx->user->getOne('Profile');
$extended = $profile->get('extended');
$extendedvalues = $extended[$container];

//compare the two and identify any matches. e.g. if checkbox1 == extendedfieldvalue1 then return a 'checked' result
for($x = 0; $x < count($checkboxvalues); $x++)
{
if(in_array($checkboxvalues[$x],$extendedvalues))
{
$selected = 'checked';
}else{
$selected = '';
}
//output the checkboxes - you can style it how you want here
$output.= '<div class="option"><input name="'.$container.'[]" number="" type="checkbox" value="'.$checkboxvalues[$x].'"'.$selected.'> '.$checkboxvalues[$x].'</input></div> ';
}

return $output;


Then in the page, use:
[[!checkbox_extended? &container=`yourextendedfieldcontainername` &boxes=`checkbox1,checkbox2,checkbox3...etc`]]


This works nicely for one container, I haven’t tried using it for multiple containers (e.g. favouritefoods, favouritecars etc.) but i don’t see why you can’t use the snippet more than once on the same page.]]>
jimbob72 Apr 28, 2011, 08:59 AM https://forums.modx.com/thread/44097/solution-using-checkboxes-to-toggle-extended-profile-fields#dis-post-253601