The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
filter comment with...
 
Notifications
Clear all

[Solved] filter comment with custom field

6 Posts
2 Users
4 Reactions
2,688 Views
(@vahid13713)
Posts: 4
Active Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 
[#3583]

Hello, How can I filter the comments displayed under a page based on a custom field? For example, if the custom field has a value of a, that comment should be displayed, and if it does not have this value, it should not be displayed.


 
Posted : 12/01/2022 1:45 pm
fueradelinea reacted
Asti
 Asti
(@asti)
Posts: 8267
Illustrious Member Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

vahid13713,

If you're a developers you can use the get_comments() and get_comment() functions. 

Also, we have plugin customization and custom addon development services at the gVectors Team. They can assess the work and create it for you. Just contact us via sales[at]gvectors.com email address and send a list of requirements you'd like to have.


In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.

 
Posted : 12/01/2022 2:23 pm
vahid13713 reacted
(@vahid13713)
Posts: 4
Active Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@asti 

Hello asti and thank you very much for your answer
I am a developer.

I get the comment with the  get_comments() function and I want wpdiscuz to show only the comments I received. How can I do this?  Please provide me with a sample code 

 

my sample code:

    $comments20 = get_comments (array ('meta_key'=> 'keytoopurl', 'meta_value'=> 'y'));

I want wpdiscuz to display only variable  comments20 

 

How can I do this?

 

 

Thanks for your cooperation

 

 


 
Posted : 13/01/2022 9:48 am
Asti
 Asti
(@asti)
Posts: 8267
Illustrious Member Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@vahid13713,

Please use this code: 

add_action('pre_get_comments', function ($queryObj) {
            $vars = $queryObj->query_vars;
            $vars['meta_key'] = 'keytoopurl';
            $vars['meta_value'] = 'y';
            $queryObj->query_vars = $vars;
    });

In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.

 
Posted : 13/01/2022 3:41 pm
vahid13713 reacted
(@vahid13713)
Posts: 4
Active Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@asti 

 

Thank you very much for your answer
I tested this code but it does not work. All comments are displayed!


 
Posted : 15/01/2022 10:43 am
(@vahid13713)
Posts: 4
Active Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@asti 

 

Hi, I have fixed the problem. I am posting content for others to use.
Your plugin caches comments, which is why our code does not work. Also, after writing the filter, it is necessary to activate and deactivate the plugin once. The problem was solved by adding the following line of code.

 

 

add_action('pre_get_comments', function ($query)
{
    $query->query_vars['meta_query'] = [
        [
            'key' => 'keyurl',
            'value' => "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"
        ]
    ];
}, 10, 1);

 
Posted : 15/01/2022 6:36 pm
fueradelinea reacted