Notifications
Clear all

Paid Addons Support Forum Only

Please note, that here we only support Paid Addons issues and questions.

gVectors Support staff works from 6am to 6pm (GMT+0)

All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:

 

wpDiscuz Support Forum wpForo Support Forum

Hidden Custom Topic Field

5 Posts
3 Users
2 Likes
210 Views
Sha.T
Posts: 5
Customer
Topic starter
(@shaleed-tonge)
Member
Joined: 3 years ago

Hi. 

I'm still looking for a way to add a contact form to my "listing". I've disabled the reply system in that specific forum and its topics, and I would like to add a third-party contact form short code in a custom field. The only thing is. I'll need this field to be hidden from the users and only visible to admin in backend. In the front-end, the user will be able to see the short code rendered in the content using a text editor post type or something similar.

Maybe if I can add the short code as a default text. 

Is this possible? 

4 Replies
Lynne Benedict
Posts: 14
Customer
(@lynne-benedict)
Member
Joined: 3 months ago

I really would love to see an answer to this question as well. We hoped with topic custom fields plugin we could store some hidden information for admin consumption only as well.  

Reply
Tom
Posts: 3977
 Tom
Admin
(@tomson)
Famed Member
Joined: 7 years ago

@lynne-benedict,

The only way is using the hook which will be available in the next wpForo version. I mean in the 2.1.0 version. The hook code should be used as PHP through Code Snippets plugin, or it should be added in functions.php file of current active WordPress theme:

add_filter('wpforo_topic_fields_filter', function( $display, $field ){
// Unique Key Names of fields you want to display only to admins
$admin_only_fields = ['field_key_1', 'field_key_2'];
if( !empty( $admin_only_fields ) && !current_user_can( 'administrator' ) ){
if( in_array( $field, $admin_only_fields, true ) ) return false;
}
return $display;
}, 10, 2);

 

In the script above, you should change the field_key_1 and filed_key_2 to the keys of your fields.

wpForo topic custom fields key

If you cannot wait till the next wpForo update (2.1.0 or to 2.0.10 version), then you can manually add the change in /wp-content/plugins/wpforo/classes/Posts.php file which will allow you to use the hook mentioned above:

Find this line:

if( $postmeta = wpfval( $postmetas, $field ) ) {

Replace it to this:

$display = apply_filters( 'wpforo_topic_fields_filter', true, $field, $post );
if( $display && $postmeta = wpfval( $postmetas, $field ) ) {
Reply
2 Replies
Sha.T
Customer
(@shaleed-tonge)
Joined: 3 years ago

Member
Posts: 5

@tomson I'll see how it works out. Thanks

Reply
Lynne Benedict
Customer
(@lynne-benedict)
Joined: 3 months ago

Member
Posts: 14

@tomson I am going to try this as well. Thank you

Reply
Share:
Scroll to top