wpDiscuz - WordPress Comment Plugin
Share:
Notifications
Clear all

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


Orakel
Posts: 72
(@orakel)
Trusted Member
Joined: 2 months 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

6 Replies
Asti
Posts: 1407
 Asti
Support
(@asti)
Support member
Joined: 3 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.

Reply
Orakel
Posts: 72
(@orakel)
Trusted Member
Joined: 2 months 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

Reply
Orakel
Posts: 72
(@orakel)
Trusted Member
Joined: 2 months ago
Posted by: @orakel

echo "Comments are deactivated in this article";

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

 

Orakel

Reply
2 Replies
Orakel
(@orakel)
Joined: 2 months ago

Trusted Member
Posts: 72

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

 

image
Reply
Asti
 Asti
Support
(@asti)
Joined: 3 years ago

Support member
Posts: 1407

@orakel,

So, can we mark this topic as solved? 

Reply
Orakel
Posts: 72
(@orakel)
Trusted Member
Joined: 2 months ago

Hello Asti

 

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

 

Orakel

Reply
Share: