Sadly there are no hooks or filters that you could use in edit-comments.php
. You’d have to build your own admin page with a custom button and use wp_set_comment_status( $comment, 'approve' );
to approve comment and do whatever you need to do…
EDIT:
I was wrong – there’s the wp_set_comment_status
action inside wp_set_comment_status
function https://wpseek.com/function/wp_set_comment_status/
do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status );
So you can just do:
add_action('wp_set_comment_status','average_rating',10,2);
and add to your function
function average_rating($comment_id, $comment_status) {
if ($comment_status == 'approve') {
.....rest of your code
Related Posts:
- get current date + 90 days and checking every day
- Changing the “Plugin Activated” Message Default
- Generate dormant hook references
- What are the package and subpackage comment for?
- Better to fire specific hooks or generic hooks with parameters?
- How to save the values of checkbox to the register setting?
- Can we hook a static method of a class to add_action inside that class?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- Filter out results from REST API
- How can I remove a hooked action created by a plugin?
- Are there any drawbacks to install IntenseDebate on my blog?
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Custom comment type maybe?
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- disable active plugins for specific theme
- Twillio How To Send SMS for Custom Post Type
- Hide WordPress Plugin Deactivation Links
- Find out if request is for custom post type archive before query runs
- Does the ‘nav_menu_css_class’ filter accept 2 or 3 arguments?
- How does WooCommerce display a custom comment_type in Comment Admin?
- do_action and hook methods
- the_posts hook, which set of posts?
- Is it possible to add an action to the currently running action?
- adding a text message beside the comment submit button
- OOP: Display warning and deactivate the plugin if PHP version is less than 5.4
- Over write plugin templates
- Replace existing pages with new pages, keep menu links
- Determine plugin name from within plugin_action_links filter
- Plugin Functionality Only for Editor and Administrator
- Easy Digital Downloads (EDD) – Purchase Receipt emails couldn’t be logged
- Placement of Code in Plugin for hooking `save_post`
- Can I use a method from an existing plugin as an action hook?
- How to initialize something in unit test before the init hook being called?
- Function to prevent users from trashing comments
- add_filter comment_edit_redirect not working
- How do you override the default comment template?
- unregistered user can write in blog page – possible? how to?
- Prevent a plugin from being automatically activated
- How get a value from a plugin into another plugin through action/filter
- Creating a plugin to sanitize comment and the url field before display only
- How do I display only the latest post on my home page, while maintaining proper plugin hooks?
- Modifying the comments section through a plugin regardless of theme
- Creating mySQL procedure with $wpdb
- WpDataTables – View Image Directory
- Get Time Taken By Each Action Hook in WordPress
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Best place for short bio,image and button [closed]
- Insert data from .sql file in wordpress plugin
- Comment section not showing correctly
- Automatic switch to backup database on fail
- password_reset hook is not working
- The Hook registration_errors was not called
- WP-DownloadManager – Query most download per week/month etc
- Template filter for custom taxonomy terms
- remove_action not removing add_action from constructor
- Can my hooked uninstall class function access a global var declared in main plugin file?
- Flag Comment as inappropriate button plugin
- Display Plugin Panels Outside of Admin Areas
- Getting error “Warning: mysql_query(): Can’t connect to local MySQL server through socket ‘FILEPATH/cccatalog-plugin.php on line 1656”
- External wpdb connections in different plugins on single page
- Plugin generating unexpected output – on WP mysql dump import
- How to hook into action/filter call
- Integrating Custom Database with WordPress
- How to automatically activate users after registration without activation email?
- Hooks to run after a core upgrade?
- Adding custom Field To The Posts Listing
- Why the internal link get converted into a comment?
- how can we migrate wordpress 5.9 website from aws ec2 to new installed wp 5.9 oci compute
- Add hook after content without formatting
- How to get the custom field value using SQL query
- Need to know if my approach to designing a geneaology plug-in for wordpress makes sense
- Using Remove Action Hook in Plugin
- admin_post hook not firing function inside class
- WordPress database problem wp_posts, primary key
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- Comment restrictions Wodpress
- Display Woocommerce attribute name above product title
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- How to see in Edit Comments if comment is from User and her Roles
- What is the correct entry point for capturing coverage data
- Add a filter to a method in the parent theme
- Publish check if the edited content has HTML “div”
- Run only on plug-in activation instead of wp_head
- Re-writing MySQl query for execute faster
- Write mysql credentials in plugin
- Help with sorting and storing data on WordPress
- page creator to leave comments ONLY
- Display_rows() and column_cb() strange behaviour
- Linking Plugin Files to WP
- MySql Query for WordPress
- How wordpress plugin hooks works? [duplicate]
- Post curl function save twice using plugin hook function wordpress
- Getting Post Permalink Outside of Loop Not Working
- which is this plugin ? [closed]
- How can I delete the options from DB when the plugin is deleted?
- Hook automatic_updates_complete to autoupdate plugin
- Suitable hook when creating, updating and deleting posts programmatically
- Change social icon in twenty twenty three theme
- is_user_logged_in() undefined at shutdown in plugin context