1. wilbert
  2. Support
  3. Thursday, August 24 2017, 10:42 AM
when a user will register, i need an option (text) which will show as a numbered list on the profiel page

1) text 1
2) text 2
3) text 3

But the user doesnot need to make the list by themself (textarea) but this needs to be done automatically
He only gives the options (text1, text2, text3)
Also user 1 has 3 inputs, and the other users has 5 inputs or something else

How is this possible?
admin Accepted Answer
Admin
Hi,
there are different ways to do this, now I have this idea: you can use text fields type to get infos from the user (registration and edit profile page) and use a textarea field type to show this in profile page, follow these steps:
1. Set all Text field type to not show in profile page
2. Create a field of type textarea, set it to show only on profile page, also set "type" to "editor" (this is useful to render HTML content in profile page, screenshot)
3. Download, install and enable our skeleton plugin (you can find it a the end of page at http://docs.easy-profile.com/index.php/article/triggers)
4. Open file /plugins/jsn/skeleton/skeleton.php
5. remove samples functions: triggerFieldAvatarUpdate, triggerProfileUpdate
6. add function like this:
public function triggerProfileUpdate($user, &$data, $changed, $isNew)
{
$content = '<ul>' ;
if( ! empty( $data[ 'text_field_alias1' ] ) ) $content .= '<li>'. $data[ 'text_field_alias1' ] .'</li>'; // add list item from text1 field
if( ! empty( $data[ 'text_field_alias2' ] ) ) $content .= '<li>'. $data[ 'text_field_alias2' ] .'</li>'; // add list item from text2 field
if( ! empty( $data[ 'text_field_alias3' ] ) ) $content .= '<li>'. $data[ 'text_field_alias3' ] .'</li>'; // add list item from text3 field
....
if( $content == '<ul>' ) $content = ''; // Reset $content if there is not text fields
else $content .= '</ul>'; // Close ul tag

// Set content in Textarea field type
$data[ 'textarea_field_alias' ] = $content;
}

NOTE: This code is not tested and not supported, this is only for example purpose.
Attachments (1)
  1. more than a month ago
  2. Support
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.