The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Custom fields visib...
 
Share:
Notifications
Clear all

Question [Solved] Custom fields visible only to logged-in users

11 Posts
2 Users
2 Reactions
193 Views
Posts: 15
 GDAG
Topic starter
(@gdag)
Eminent Member
Joined: 4 months ago

Hello,

I've added some fields to the comment form. I would like the values of these fields in the comment list to be visible only to users connected to Wordpress. Is it possible to do this?

I look forward to hearing from you,

10 Replies
Asti
Posts: 7261
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

Hi,

Sure there is an option called "Display for Guests:". You should disable it. Please watch this video: 

Reply
Posts: 15
 GDAG
Topic starter
(@gdag)
Eminent Member
Joined: 4 months ago

Thank you for your responsiveness. However, I would like everyone to complete it (logged in or not) but only logged in users can see this field in the list of comments (This is private data but useful for administrators).

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7261

@gdag,

You can use the CSS code provided below:

.wpdiscuz_unauth .wpd-custom-field.yourCustomfieldClassname {display :none !important;}

Just change the yourCustomfieldClassname to the one you've created. Each field has its specific classname. 

Insert the code in the "Custom CSS code" textarea, located in the Dashboard > wpDiscuz > Settings > Styles & Colors admin page.

Don't forget to delete the caches before checking.

 

Reply
Posts: 15
 GDAG
Topic starter
(@gdag)
Eminent Member
Joined: 4 months ago

Thank you for your reply. This solution, although visually perfect, seems to me very risky and not very recommended for the protection of users' private data (one look in the HTML code with the inspector and everything is visible). Don't you have an idea for a more suitable solution (Filter , Action...)?

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7261

@gdag,

You can use JavaScript code:

jQuery( document ).ready(function() {
       jQuery('.wpdiscuz_unauth .wpd-custom-field.yourCustomfieldClassname ').remove();
});

For guidance on adding JavaScript to WordPress pages, you may find this article helpful: https://www.wpbeginner.com/wp-tutorials/how-to-easily-add-javascript-in-wordpress-pages-or-posts/

Reply
Posts: 15
 GDAG
Topic starter
(@gdag)
Eminent Member
Joined: 4 months ago

Thanks for this solution, which already seems more secure. However, isn't it really possible to do this not in JS but in functions.php in order to be completely secure?

Reply
4 Replies
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7261

I'll check with the developers to see if they can provide a solution for you. I'll update this topic as soon as I have more information.

Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7261

@gdag,

The developers will add a new hook. Once the new version of the wpDiscuz plugin is released, you'll be able to use the PHP code.

Reply
 GDAG
(@gdag)
Joined: 4 months ago

Eminent Member
Posts: 15

@asti

Thanks for the good news 🙂 Another question: is it possible for logged-in users to see commenters' e-mail addresses?

Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7261

@gdag 

I'm really sorry, but the wpDiscuz doesn't have such a feather. 

Reply
Share: