The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Changng output text...
 
Share:
Notifications
Clear all

[Solved] Changng output text for disabled coments for user (global) and single user

9 Posts
2 Users
1 Reactions
867 Views
Posts: 104
Topic starter
(@orakel)
Estimable Member
Joined: 4 years ago

Hello all, hello dear Asti

 

Some Weeks ago, you helped me to show a textline above the comment section, if comments are disabled,

 


add_action("wpdiscuz_comment_form_closed", function ($post, $currentUser, $commentsCount) {
echo "Comments are deactivated in this article";
}, 10, 3)

 

Yesterday i got it to work, to disable the comment form for a specific (comment banned) user.

It´s this lines if anyone like it:

 

just make a new role with only "read" permission, example name = locked)

add_filter( 'init', function()
{
$u = wp_get_current_user();

if( $u->exists() && in_array( 'locked', $u->roles, true ) )
add_filter( 'comments_open', '__return_false' );
} );

 

My question now is, how i get it to work to show different messages if its a post related comment close like the code at first (Comments are deactivated in this article) or a userrole related message like "You are not allowed to post comments".

Is it possible to include the second message with a if else code like if userrole = banned shwow this, if not show this, in that codelines?

add_action("wpdiscuz_comment_form_closed", function ($post, $currentUser, $commentsCount) {
echo "Comments are deactivated in this article";
If userrole = banned echo "you are locked and not possible to write a comment"
}, 10, 3)

 

further i was searchng for the css class (ok i am a realy new on css bt learning fast)

how can i format this text inside the php echo?

 

Thanks in adcance

Orakel

8 Replies
Asti
Posts: 7617
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

@orakel,

You should use the hook provided by us and add custom code for either displaying the first message or the second one.

how can i format this text inside the php echo?

You can add your custom HTML codes with some classes, then apply the CSS rules for those classes.

Posts: 104
Topic starter
(@orakel)
Estimable Member
Joined: 4 years ago

Hello dear Asti

 

I know the problem with the different messages are not wpdiscuz related, but you are so very helpfull in all.

I am not a good coder but i try to learn. Would it be ok for you to give me an example how i can get this different messages?

 

Thanks in advance

Orakel

Posts: 104
Topic starter
(@orakel)
Estimable Member
Joined: 4 years ago
Posted by: @orakel

echo "Comments are deactivated in this article";

Can you explain how i define a class into the echo command?

 

Orakel

2 Replies
(@orakel)
Joined: 4 years ago

Estimable Member
Posts: 104

got it to work with the formating text and own css style ^^

 

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

Illustrious Member
Posts: 7617

@orakel,

So, can we mark this topic as solved? 

Posts: 104
Topic starter
(@orakel)
Estimable Member
Joined: 4 years ago

Hello Asti

 

If you can, i would still need help, with the different messages :/

 

Orakel

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

Illustrious Member
Posts: 7617

@orakel,

use this code:

add_action("wpdiscuz_comment_form_closed", function ($post, $currentUser, $commentsCount) {
if (!empty($currentUser->ID) && in_array("banned", $currentUser->roles)) {
echo "you are locked and not possible to write a comment";
} else {
echo "Comments are deactivated in this article";
}
}, 10, 3);

Put it in the active theme functions.php file.

Posts: 104
Topic starter
(@orakel)
Estimable Member
Joined: 4 years ago

Hello Asti

 

This works great, thank you very much =)

 

Orakel

Share: