I've made use of the "signupfields" component and figured out how to amend the fields required at signup nice and easily.
I need to add a "Preferences" array, but only on the user fields in the profile page. I don't want it to appear on the signup page. (ie its only optional - and not required for signup)
If I include the "prefs" array in the merge with the "gender" signup fields, it appears on the signup page AND the profile page. But if I split it out, it doesnt seem to appear anywhere. And I think that may be because its not a part of the "required" array?
This is in the init section:
ossn_add_hook('user', 'signup:fields', 'signup_fields');
ossn_add_hook('user', 'default:fields', 'signup_fields');
ossn_add_hook('user', 'default:fields', 'prefs_fields');
This is the Gender function that works perfectly:
function signup_fields($hook, $type, $val, $params){
$toremove = array(
"gender"
);
$return = ossn_remove_field_from_fields($toremove, $val);
$fields = array();
$fields['gender'] =
array(
'checkbox' => array(
array(
'name' => 'gender',
'options' => array(
'individual' => ossn_print('com:prefs:individual'),
'couple' => ossn_print('com:prefs:couple'),
'business' => ossn_print('com:prefs:business'))
)
)
);
return array_merge($return, $fields);
}
And this is the code that doesn't work:
function prefs_fields($hook, $type, $val, $params){
$fields = array();
$fields['prefs'] =
array(
'checkbox' => array(
array(
'name' => 'prefs',
'options' => array(
'160' => ossn_print('com:prefs:160'),
'161' => ossn_print('com:prefs:161'),
'162' => ossn_print('com:prefs:162'),
'163' => ossn_print('com:prefs:163'),
'164' => ossn_print('com:prefs:164'))
)
)
);
return array_merge($return, $fields);
}
Do I need to extend the ossnuser or hook this in somewhere else perhaps?
Any thoughts/suggestions gratefully accepted :)
Thanks
kev
Hi, i suggest you to upload code to http://github.com/ for development, so we can take a look into it
ok thanks Malik. Ive already seen the signup component - that's what this was based on. I've just gone one step further.
And regards the commercial components - that's good to know thank you. However, I have written the whole component myself and im pretty sure its just one line of code that needs tweaking.
There are LOADS of components I intend to purchase, and also upgrade to Premium once I establish a community - but for the moment I need to launch this without a budget. If I had the budget i'd just buy the premium version now and have done with it! :D
I've added a location field with a dropdown to choose towns/countries too, it creates the database entry but the value is still blank. I'm sure its just one little tweak and one experienced developer will be able to solve it in seconds :D
Thanks
Kev
Sorry wrong link previusly
https://www.softlab24.com/product/view/4261/custom-user-fields
http://homelancer.com/download/home-custom-fields/
Look at this
https://www.opensource-socialnetwork.org/component/view/959/signup-fields
and the component you are try to creating is already available
Sorry, link is case sensitive. New link:
Swing3rsPrefs Component
If anybody is able to shed some light on the lack of data being written to the database that'd be much appreciated :)
Ta
the link you provide for component is broken
upload your code to GitHub and provide more better
Thanks Malik.
My component is looking better. It allows me to specify fields that appear on the signup page, as well as optional fields that only appear on the profile edit page now. I think this could be a component that would benefit the community so i'll look to release it once complete.
I have one little snag though, the new fields appear on the profile edit page, but when I post them, they don't save in the database? If I look at the POST data in the browser, its definitely posting the correct data, and there is a blank entry being added to the entities table, but it doesn't contain any data.
I'd be grateful if somebody could help me with this bit - all I need is for it to save to the sql table, then the component is finished :)
I have uploaded the component here: Swing3rsPrefs Component
Take a look at those components code
https://www.opensource-socialnetwork.org/component/view/2449/m-country
https://www.opensource-socialnetwork.org/component/view/2424/bio
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)