Access to Custom Profile Fields

Discussion forum for MOD Writers regarding MOD Development.
Mjkn
Registered User
Posts: 3
Joined: Tue Feb 05, 2008 4:39 pm

Re: Access to Custom Profile Fields

Post by Mjkn »

Hi, I tried Atrox's method and got this message:

Code: Select all

Fatal error: Call to undefined method custom_profile::build_cache_full() in /var/www/web2/something.tld/community.something.tld/includes/functions_profile_fields.php on line 413
Atrox
Registered User
Posts: 108
Joined: Tue Jan 21, 2003 6:26 pm
Contact:

Re: Access to Custom Profile Fields

Post by Atrox »

Ah, that's what I forgot to include! Thanks.

Find this:

Code: Select all

        /**
        * Get language entries for options and store them here for later use
        */
        function get_option_lang($field_id, $lang_id, $field_type, $preview)
Then put this code above it:

Code: Select all

        function build_cache_full()
        {
                global $db, $user, $auth;

                $this->profile_cache = array();

                // Display hidden/no_view fields for admin/moderator
                $sql = 'SELECT l.*, f.*
                        FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
                        WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
                                AND f.field_active = 1 ' .
                                ((!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? '    AND f.field_hide = 0 ' : '') . '
                                AND l.field_id = f.field_id
                        ORDER BY f.field_order';
                $result = $db->sql_query($sql);


                while ($row = $db->sql_fetchrow($result))
                {
                        $this->profile_cache[$row['field_ident']] = $row;
                }
                $db->sql_freeresult($result);
        }
Mjkn
Registered User
Posts: 3
Joined: Tue Feb 05, 2008 4:39 pm

Re: Access to Custom Profile Fields

Post by Mjkn »

Ok, another problem :D
I've edited functions_profile_fields.php, created php and html page, but if I open that php page, i see only header and footer, no profile field values... if I type page.php?u=2, i don't see that, too.

I think that I'm stupid and I made something wrong... and I can't speak english :D
Atrox
Registered User
Posts: 108
Joined: Tue Jan 21, 2003 6:26 pm
Contact:

Re: Access to Custom Profile Fields

Post by Atrox »

Lets see your php and html pages.
User avatar
karnesb
Registered User
Posts: 9
Joined: Wed Jul 16, 2008 11:53 pm

Re: Access to Custom Profile Fields

Post by karnesb »

Atrox,

I tried your profile mod and wasn't sure where to put the code you identified in the box below this phrase:
To use it, put the following code in the php file that corresponds to the template file you want to use:.

I'm trying to do a greeting in my overall_header.html file that would display the user's first name only, and read something like

Welcome {PROFILE_FIRST_NAME_VALUE}!

I'm guessing your code will work, and had no problems updating the includes/functions_profile_fields.php file. Just don't know what php file would correspond to the overall_header.html templete file I'm using in order to paste the referenced code above.

Can you help?
Thanks
Barbara
Wulfric
Registered User
Posts: 26
Joined: Fri Nov 13, 2009 8:09 am

Re: Access to Custom Profile Fields

Post by Wulfric »

Not working for me. I edited the function field correctly I think, but it is not showing up on the page when I call through {PROFILE_FIELD_NAME} etc
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52062
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Access to Custom Profile Fields

Post by Brf »

Wulfric wrote:Not working for me.
I assume this refers to your previous post on the subject. You still have not answered the question there.
Wulfric
Registered User
Posts: 26
Joined: Fri Nov 13, 2009 8:09 am

Re: Access to Custom Profile Fields

Post by Wulfric »

I answered there now, about this, I have another doubt, what do I put in PROFILE_NAME? My Name of Profile field has space in it. and ID has _ in it.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52062
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Access to Custom Profile Fields

Post by Brf »

You question has been answered in the other topic.
kantzorf
Registered User
Posts: 4
Joined: Sat Dec 13, 2008 8:50 pm

Re: Access to Custom Profile Fields

Post by kantzorf »

I need a little help :D.

I managed to get the custom field using (in viewtopic.php)

Code: Select all

    $user->get_profile_fields( $user->data['user_id'] );
    $user->profile_fields['pf_LFSW_USER'];
but I need posters custom profile field, not the cpf of the user reading that post.
I think i have to change that "user_id", but i'm not sure...
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52062
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Access to Custom Profile Fields

Post by Brf »

viewtopic already gets all of the profile fields for the post author. You do not have to do anything in viewtopic.php to use them. Refer to this topic for details: http://www.phpbb.com/community/viewtopi ... 1&t=582444
kantzorf
Registered User
Posts: 4
Joined: Sat Dec 13, 2008 8:50 pm

Re: Access to Custom Profile Fields

Post by kantzorf »

Yes, I know. But I want to show under the user name an image with this kind of URL:

Code: Select all

http://domain.com/blabla.PF_FIELD
I don't know how I can do that in HTML and i thought is a good idea to merge them (url+pf_field) in viewtopic.php...
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52062
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Access to Custom Profile Fields

Post by Brf »

You can do that in the HTML.
Replace

Code: Select all

{postrow.custom_fields.PROFILE_FIELD_VALUE}
with

Code: Select all

		<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME == "LFS Number" -->
		<a href="http://www.example.com/{postrow.custom_fields.PROFILE_FIELD_VALUE}">{postrow.custom_fields.PROFILE_FIELD_VALUE}</a><!-- ELSE -->
{postrow.custom_fields.PROFILE_FIELD_VALUE}<!-- ENDIF -->
kantzorf
Registered User
Posts: 4
Joined: Sat Dec 13, 2008 8:50 pm

Re: Access to Custom Profile Fields

Post by kantzorf »

Thanks for your help, it works ;) .
Locked

Return to “[3.0.x] MOD Writers Discussion”