HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Custom Profile Fields

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#41518 (In Topic #9294)
Avatar

Honoured member

Hello there,

I'm working on something for my chat.
Is there a way to get the info that is in a custom profile field without making a new php script for it?
It's to show them on a diffrent page as the profile page.


Kind regards,
Turbo_boy
Back to the top
 
Posted
Rating:
#41581
Avatar

Hi,

Currently this is not possible without such a PHP script.
But this is a good example of how a miniblock can be used so I have written a little script for you…

This is sources_custom/miniblocks/cpf_value.php:

Code

<?php

$member=array_key_exists('member',$map)?intval($map['member']):get_member();
$field_id=array_key_exists('field_id',$map)?$map['field_id']:'';

require_code('ocf_members');
$info=ocf_get_all_custom_fields_match_member($member);
if (array_key_exists($field_id,$info))
   echo $info[$field_id];
else echo 'No such field (fields available are '.implode(',',array_keys($info)).')';

which can be called like:

Code

[block member="2" field_id="Staff notes"]cpf_value[/block]
from Comcode, or like:

Code

{$BLOCK,block=cpf_value,member=2,field_id=Staff notes}
from Tempcode.

Where 'field_id' is the name of a custom profile field, and member is a member ID.

If you just want the current member's value, you can leave out the 'member' parameter.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
Posted
Rating:
#41585
Avatar

Honoured member

Thank you.

O ps. Should not that php code and up with ?>
Back to the top
 
Posted
Rating:
#41586
Avatar

This isn't well known, but it doesn't need to. Since v4 we've not been putting ?> on the end of our code because some text editors add extra space on the end and if there's extra space after "?>" cookies can stop working.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
Posted
Rating:
#41587
Avatar

Honoured member

oke, well it works so its ok :)
Back to the top
 
Posted
Rating:
#41591
Avatar

Community saint


Chris Graham said

This isn't well known, but it doesn't need to. Since v4 we've not been putting ?> on the end of our code because some text editors add extra space on the end and if there's extra space after "?>" cookies can stop working.
Yep thats why some scripts like IPB come with white space scanners.  :thumbs:

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: