Notifications
Clear all

How to display the custom fields in the post.php & topic.php

11 Posts
5 Users
0 Reactions
12.7 K Views
Posts: 19
Customer
Topic starter
(@mister)
Member
Joined: 7 years ago

Hello

I want to display the custom fields in the templates "post.php" and "topic.php".
Can you tell me how to achieve inclusion in php because I did not find the solution in the documentation.

Waiting to hear from you

MP

10 Replies
Posts: 19
Customer
Topic starter
(@mister)
Member
Joined: 7 years ago

Do you have a solution to propose ?

Reply
Astghik
Posts: 6149
Admin
(@astgh)
Illustrious Member
Joined: 7 years ago

Hi Mister,

You can get the field information and display it by using these functions.

For wpForo 1.4.7 and higher versions use this function:

<?php wpforo_user_field( 'field_name' ); ?>

 

For 1.4.6 and lower you only can use wpForo User Custom Fields addon functions:

1. This function gets the field information by userId and fieldname and return it. You can print $fieldValue value anywhere you want.

 

 if (function_exists('wpfucfGetField')) {
$fieldValue = wpfucfGetField($userId, $fieldName);
}

 

2. This function prints the field information by userId and fieldname with before and after html parameters

 

if (function_exists('wpfucfTheField')) {
wpfucfTheField($userId, $fieldName, $before = '', $after = '');
}
Reply
1 Reply
Customer
(@joshua-hidalgo)
Joined: 5 years ago

Member
Posts: 9

@astghik Where do you place this function within the post.php file?

Reply
Posts: 19
Customer
Topic starter
(@mister)
Member
Joined: 7 years ago

Thank you for the answer.

So if I understand well to display a custom field called "coupdroit" or "bois" or "nomclub", the function will be written as well :

<?php if (function_exists('wpfucfTheField')) {
wpfucfTheField($userId, $coupdroit, $before = '', $after = '');
} ?>

or

<?php if (function_exists('wpfucfTheField')) {
wpfucfTheField($userId, $bois, $before = '', $after = '');
} ?>

or

<?php if (function_exists('wpfucfTheField')) {
wpfucfTheField($userId, $nomclub, $before = '', $after = '');
} ?>

I tried with these examples but it does not work. I tried with a field included in the plugin with for example "site" but it does not work either.

Can you tell me where my mistake comes from?

thank you in advance

MP

Reply
1 Reply
Astghik
Admin
(@astgh)
Joined: 7 years ago

Illustrious Member
Posts: 6149

For example, for the field "coupdroit" and user with id 15 the functions will be like this. 

if (function_exists('wpfucfGetField')) {
$fieldValue = wpfucfGetField(15, "coupdroit");
}

and

if (function_exists('wpfucfTheField')) {
wpfucfTheField(15, "coupdroit", $before = '<h4>', $after = '</h4>');
}

Reply
Posts: 19
Customer
Topic starter
(@mister)
Member
Joined: 7 years ago

Thank you that works well but only for a user.
How to make the & id value suitable for all forum users?

This information is displayed in the user's information and is displayed in the view of everyone.

Thanks you

Capture d’écran 2018 02 23 à 22.17.04
Reply
Page 1 / 2
Share:
Scroll to top