Support Forum
Custom Profile Field w Defaults?
Yellow Swordfish
Glinton, England
SP Master
Offline
It is actually more complicated than we would like - simply because of the checks that need to be made on the value. For example - if it is NOT checked... how do you know it is not checked on purpose by the user - as opposed to an original default?
The following is about the only way I can think of doing it safely. The following code assumes that the slug of the custom profile field checkbox is 'magsub'. You can find the actual slug in the CPF creation admin panel.
So - you could put this in the spFunctipns.php file of your SP child theme (in the .templates folder). And change ALL instances of 'magsub' to the real slug. This will ONLY set the default on for the first time it appears in a users profile form.
add_filter('sph_custom_profile_fields_magsub', 'set_default_magsub'); function set_default_magsub($cb) { global $spProfileUser; $d = spdb_select('row', "SELECT * FROM ".SFUSERMETA." WHERE user_id = ".$spProfileUser->ID." AND meta_key = 'magsub'"); if (empty($d)) { $f = array(); $f = explode('"checkbox" ', $cb); $cb = $f[0] . '"checkbox" checked="checked" ' . $f[1]; } return $cb; }
YELLOW
SWORDFISH
|
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625