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
- WP Plugin: How to avoid db access for each comment?
- Inserting above the comment template
- Insert new user with form submit ‘init’ hook
- Creating a plugin to sanitize comment and the url field before display only
- How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
- How do I display only the latest post on my home page, while maintaining proper plugin hooks?
- Help With MySQL to WPDB Query Conversion
- Hooking in to replace the Sidebar/Widget areas
- How to get all of the activate_plugin action parameters?
- Modifying the comments section through a plugin regardless of theme
- Creating mySQL procedure with $wpdb
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- Using a post-signup hook to get user details
- Map a custom id to wordpress post id
- WordPress comments not appearing in blog posts, likely because of Redux template. Could I fix this with a plugin that adds a comment form as a block? [closed]
- woocommerce_package_rates not fired when wordpress woocommerce accessed as non ajax
- Trigger Elementor Popup via code [closed]
- wp_get_post_terms is difference obj model than the one in rest api response
- Calling plugin function inside custom plugin for onclick event
- WpDataTables – View Image Directory
- join 2 table orders wordpress plugin
- How do I run SQL queries on a WordPress web page? [closed]
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- How can I perform high-level database merging for WordPress within continues delivery?
- Get Time Taken By Each Action Hook in WordPress
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- Send reply with pre-prepared answers
- posts comments goes to trash
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- Plugin: register_deactivation_hook works perfectly well, while register_activation_hook suddenly stopped working
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Enabling WP_USE_EXT_MYSQL to support old plugin
- Filtering WooCommerce Orders by Category
- Best place for short bio,image and button [closed]
- how to access all user dashboard on fronted page [closed]
- Insert data from .sql file in wordpress plugin
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- WordPress Backend HA (Automatic failover)
- Comment section not showing correctly
- Disqus deleted comments are syncing with wordpress but active comments do not
- Automatic switch to backup database on fail
- SQL to order by CPT results by user->display_name w/only user->ID known
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- Include comments form in plugin page
- Enabling plugin failed because MySQL user do not have CREATE permissions
- WordPress page and plugin list using sql query
- do_action() hook into load-(page)
- WordPress 4.2.1 pre_get_comments doesn’t work after update
- Multiple instance of data in plugin custom database table on plugin activation
- Howto check version of another plugin and then add a submenu page to it
- password_reset hook is not working
- The Hook registration_errors was not called
- Integrate Facebook comments with native comments
- Post Comments with Ajax in WordPress
- Notify comment author upon reply
- Hook into existing tinyMCE button
- allow photo/video in comments
- WP-DownloadManager – Query most download per week/month etc
- Better ads plugin has 500.000 entries in wp_postmeta
- How to get post ID with hooks publish_post, new_to_publish, etc
- edit_user_profile and show_user_profile are not firing inside a class
- Template filter for custom taxonomy terms
- Errors when trying to use a plugin to write to the database
- _prime_post_caches in wordpress
- pagination on data fetched using SQL query
- Add sub menu page in your plugin
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- how to change automatic placing of social plugins below content?
- Custom setup of wordpress comments that are displayed
- Speeding SQL queries for a large database?
- Is there a specific term for Plugins that are specified in a WordPress Post using Comments?
- Cannot get wpdb data (Error in a simple fuction) [closed]
- Mass SQL WordPress Meta Key deletion
- What exactly happens to function argument availability when using a filter?
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- Combining several CSS files into one for optimization
- the_post hook is not firing for me
- dbDelta not adding additional columns in plugin database update
- Why do plugins often ask to add in to templates?
- Deactivate JS Script in Plugin Shortcode
- Add back to post link on blank comment post error page
- Create a post builder skin in a plugin
- remove_action not removing add_action from constructor
- Plugin Development – Functions or Hooks?
- Using ‘mysqli_connect’ ‘crashes’ WordPress client-side
- How to get menu location in wp_update_nav_menu hook
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Can my hooked uninstall class function access a global var declared in main plugin file?
- Flipping Book PHP Code? Any experience?
- Turning on output buffering in a wordpress plugin
- Hook for page Request?
- Flag Comment as inappropriate button plugin
- Display Plugin Panels Outside of Admin Areas
- Are there action hooks for comments?
- How to remove js ui library added by default by wordpress
- How to use template_include hook with form submission?
- Adding Plugin Assets to Header
- Add item to the woocommerce dashboard menu from a plugin
- Help with comments.php