Notifications
Clear all

How to work with a plugin that hides content but does not hide comments?

14 Posts
2 Users
1 Likes
2,070 Views
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  

Good day.

In my WordPress theme I use a plugin for paid access to content. Content is hidden either in the settings or using the shortcode from users who did not pay for access.

Comments by this plugin (access) are not hidden 🙁

We found a way to change this. A small code that rules the theme function.php and a link to it with the condition in the comment.php.

Then we set your comments plugin. And comments in paid entries became visible again 🙁

Tell me, please, in which file and in which part of the code do I need to add a check for the fact that the user has paid access before uploading the comment form to him?

Thank you.


   
Quote
Topic Tags
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5858
 

Hi @dm1,

First of all, thank you for using wpDiscuz!

Please navigate to Dashboard > Comments > Forms admin page, edit the "Default form" and Disable commenting for certain roles.

More info here:

https://wpdiscuz.com/docs/wpdiscuz-documentation/getting-started/custom-comment-form/comment-form-settings/#disable_commenting_for_roles


   
ReplyQuote
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  

Thanks for the response. But in the paid access plugin I have other user statuses.

It is necessary to edit the code.

For ordinary WordPress comments, we did the following:

1. added additional code to the theme function.php:

function wau_is_comments_access(){
    global $WAU_User, $WAU_Post, $post;

    if(wau_get_option('author-show') && $WAU_User->user_id == $post->post_author) return true;

    if(!wau_check_post_type(get_post_type($post))) return true;

    if($accountIds = wau_get_post_closed_term_ids($post->ID)){

        return false;

    }

    if(!$WAU_Post || !$WAU_Post->access || $WAU_Post->post_id != $post->ID) return true;

    $account_ids = array();

    if ($WAU_Post->options['important']) {

        foreach ($WAU_Post->access as $access) {
            if (!$WAU_User->is_branch_access($access->account_id, 1)) {
                $account_ids[] = $access->account_id;
            }
        }

        if(!$account_ids)
            return true;

    } else {

        $account_ids = $WAU_Post->get_account_ids();

        if($WAU_User->is_branch_access($account_ids, 0)){
            return true;
        }

    }

    return false;

}

2. added additional code to the theme comment .php:

if(!wau_is_comments_access()){
	return false;
}

In which file and in which place can this code be entered (point 2) in your theme? Or advise something else. Thank you.


   
ReplyQuote
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  
Posted by: Astghik

More info here:

https://wpdiscuz.com/docs/wpdiscuz-documentation/getting-started/custom-comment-form/comment-form-settings/#disable_commenting_for_roles

I read everything. Thank you. I Answered above.


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5858
 

Hi @dm1,

Sorry for the delay. 

You should customize comment-form.php file. This file you can find in  wp-content/plugins/wpdiscuz/templates/comment folder. 


   
ReplyQuote
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  

And how are the comments displayed? Where does this code start? Which line?


   
ReplyQuote
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  

Also tell me please how to make these code changes in the comment-form.php not disappear when updating your plugin? Should I disable plugin update? How?

Or is there another way? With moving files?


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5858
 

Hi @dm1,

And how are the comments displayed? Where does this code start? Which line?

you should add the code approximately on the 178 line. I think you should make changes in this part of the code:

 if ($commentsOpen) {
$wpdiscuz->helper->superSocializerFix();
$formCustomCss = $form->getCustomCSS();
if ($formCustomCss) {
echo '<style type="text/css">' . $formCustomCss . '</style>';
}

I'm sorry, but there is no way to make these changes in update save way. You just need to keep this code and make the changes after each update. 


   
ReplyQuote
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  

Tell me, are your plugin updates automatic? Or I can it be adjusted manually?


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5858
 

Hi @dm1,

If you don't enable automatic updates for WordPress plugins, wpDiscuz will not be updated automatically. It'll display the following message: "There is a new version of wpDiscuz available. View version 5.3.1 details or update now. " and until you don't click on "update now" link it will not be updated. 

update

 


   
dm1 reacted
ReplyQuote
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  

Thanks.


   
ReplyQuote
 dm1
(@dm1)
Eminent Member
Joined: 5 years ago
Posts: 32
Topic starter  

In continuation of the topic is another question. About hiding the sending of notifications about the user's comments. In this feature https://wpdiscuz.com/docs/wpdiscuz-documentation/settings/email-subscription/#user_follow

For example, User 2 subscribed to the comments of Author 1. This Author writes including posts that are available only on paid accounts (as described at the very beginning of this topic). In these (paid) posts the author writes comments.

Where is the code that describes the newsletter and is it possible to somehow insert a filter there so that comments from paid topics do not go away to all users, but only to those who have a certain additional status in another plugin (responsible for access)?


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5858
 

@dm1,

I'll ask developers and let you know asap. 


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5858
 

@dm1,

The only way I can suggest you is using the wpdiscuz_email_notification hook. 

Also could you please check one more time and let us know if the custom roles are not appearing in "Disable commenting for roles" list. 

Disable commenting for roles

   
ReplyQuote
Share:
Scroll to top