You could just add something like:
// Remove 1 point if their post get removed
function deletePointFromUser($post_id) {
$post = get_post($post_id);
if( $post->post_type != 'post' ) return;//added code
$authorid = $post->post_author;
$currentQPointNumber = get_user_meta($authorid, 'points', true);
// Delete 1 to the current Point Score
update_user_meta($authorid, 'points', $currentQPointNumber-1);
}
add_action('wp_trash_post', 'deletePointFromUser');
Then your point subtraction will only occur if the $post
is a post.
Related Posts:
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Is it ok to use a function to output the text domain name in a wordpress theme
- Issue with wp_get_attachment_image() and SVG file type
- How to override a function when isn’t at functions.php
- deregister scripts on certain page
- contactform7 remove tags with “wpcf7_autop false” from functions.php
- How to count number of functions attached to an action hook?
- Show modified time if post is actually modified
- ajax live search for post title
- How to get an array of menu items from the toolbar?
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Using get_terms for custom taxonomy in functions.php
- Fatal error: Call to undefined function add_action() – an untouched problem
- Hide some items from Screen options in dashboard for products
- Editing or filtering the output of the Genesis navigation
- Automatically Add Specified Value to Attachment Metadata upon Upload
- Twenty Eleven Child theme error when attempting to use a rewritten function
- edit role display name and label name without plugins
- is_plugin_active() not properly returning true
- Display gallery on top before content
- List of Body Classes Generated by body_class()
- Converting html to wordpress images not showing
- is_dynamic_sidebar always returns true while using Jetpack visibility
- post to subcategory and parent in wp_insert_post
- Replace menu links with # and add name to its li
- Variable if post is sticky in functions.php
- Retrieve tags data in post body
- Remove H1 / title / Underscore – without CSS
- Change template on the fly based on post parent selection
- Current path on page in functions.php
- How do you publish a draft on WordPress
- How can I recompile js file in dist folder?
- Show Primary Category first when I display post categories
- Wp_query function to search from product_title ‘OR’ product tags name
- Create a new query in function.php to filter blog posts
- Use third party Library in wordpress
- Remove the product category module block from the Woocommerce product page
- Setting youtube size in functions.php
- How to get correct URLs in network wide menu (Multisite)?
- wp_get_archives custom function broken since upgrading to WP 3.7.1
- Remove category from url
- ‘Attempt to modify property of non-object’ warning
- Conditional functions.php on page template
- Optimizing a WordPress site
- different style sheet for just one page template
- Problem with comments_number()
- Functions when woocommerce isn’t installed
- How to target post and pages and not all post types in admin?
- How to get correct value from checked()?
- Dequeue script to prevent javascript event conflict on wordpress child theme
- While loop with an exception after a count is reached
- Return child theme url
- Redefine function arguments before rendering
- Passing global variable from header.php to functions.php
- How is $current_page passed in woocommerce_account_orders function?
- Upgraded server now class My_Walker_Nav_Menu extends Walker_Nav_Menu not working
- Functions php shortcode for displaying main menu with no child items
- How to include any template using Shortcode fuction?
- display a div on ervery site but not frontpage?
- first paragraph of the_content as meta description
- Do we need to change our child function.php to require/include child dir files when we add an over-riding file.php into the child theme
- How do I pull avatar from post using BuddyPress? [closed]
- Replace header image on all other pages but home – URL issue
- Child theme functions.php
- How to echo Widget Title in Custom Frontend-Template Box
- Redirect to post after publish or update a published post
- Page Template Won’t Load Correct CSS File
- Getting images from media library and get_the_date() not working
- WordPress show bad the php hour and date
- Using add_image_size in functions.php to get original uploaded file
- show all the posts thumbnails
- the_excerpt function not showing image
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- Use a filter for wp_robots to block CPT/feed/
- How do I change where “You must be logged in to comment” directs users?
- Login cookies blocked after customizing hashing method
- Order column custom date using pre_get_posts
- query_vars treat as single var from URL
- Running javascript without hooking wp_head
- Remove text after a dot and a colon in Woocommerce product title
- Enable CORS Request for hostname using IP address
- Change default color scheme in twentyfifteen child theme?
- Restrict access if logged out except for homepage
- Add meta data in head from theme
- what is `get_section()` and how to use it?
- DISABLE wordpress upgrade page
- How to echo the translated custom field?
- Only Show One Category Name Per Post
- How to list out all values from the get_body_class array
- Moving CDN jQuery to footer does not work?
- Pass max posts to Javascript
- Register a widget area when a theme option has been saved?
- Blank child theme – functions.php problem
- update_usermeta don’t work
- Hiding Google Analytics code based on theme options
- How do I make my child theme’s CSS update when I save it?
- Bulk set Post Title as Tag where Tag is Empty Function
- How do i set global variable in a function in wordpress functions.php
- Working function() doesn’t execute when triggered by WP CRON
- post_row_actions filter from parent theme not executing in child theme