Firstly, it’s better to user WP functions than write your own SQL. Even though it might be a bit more expensive:
$post = get_post($post_ID);
$authorid = $post->post_author;
Secondly, it’s not get_usermeta()
, but get_user_meta()
and the complete call should include true
as the third parameter:
$currentPointNumber = get_user_meta($authorid, 'points', true);
And then it’s update_user_meta()
, again, and you don’t need to initialize a new variable, just do:
update_user_meta($authorid, 'points', $currentPointNumber-1);
Related Posts:
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- How can I list random authors from current post category?
- Change all author links in Blog roll
- how to show comments only author which send own posts in wordpress
- Changing the post date and time with function
- Get current post id in functions.php
- Dynamically add id to heading tags
- the_author() returns empty string
- Prevent Authors from viewing each others Posts
- How to show list of posts by author and category?
- How to publish a post with empty title and empty content?
- Different permalink for posts and authors
- How to display posts by current user/author in a custom page template?
- How to call function within a page/post, to dynamically generate content?
- How do I use element instead of tags in WordPress post content having webP support?
- Restrict the Number of Posts an Author can Publish (over time)?
- Search posts by post author name
- Find most recent authors
- Show author post count in sidebar – Variable
- Get the author of the latest revision
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Human Time Diff, change mins to minutes
- How to get new post URL?
- Force update all posts in custom post type, no content changes
- Disable REST API for a user ROLE
- How to Display Post View Count
- Remove double space after a period
- Add confirmation popup on “Move to Trash”
- Multiple authors for single post without plugin
- Limit number of posts a user can make per minute?
- $post object is null
- Author must complete profile info before they can publish a post?
- How to change the page break URL from ../post/2 to …/post/page2/
- Run a function when post is deleted?
- Getting current post ID in functions.php
- How can I show wordpress posts based on author?
- Add icon/badge next to posttitle of specific category
- Auto “expire” all of an authors posts on spcific date
- How to get the user meta data for a post?
- How can I show many posts an author has per week?
- How to give capability (publish contributors posts) to author role?
- Load post attached images on a single page site with fancybox
- Whitelist Author of Private Post
- Exclude category from
- Setting posts_per_page for taxonomy term template
- Change post order random through out the entire WordPress
- Can’t get buddypress notifications in front-end; why do I get this error?
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Send post id through ajax and get the post content back
- Force authors to Preview a post before publishing
- Display author’s name and avatar in post’s sidebar
- Format latest/newest post differently
- is_page Funtion for Posts ?
- How to only publish posts with image in it
- Isn’t the way posts are displayed very unefficient?
- Is it possible to lock all new and existing WordPress posts to one specific author?
- restrict incrementation of post vies count when refreshing the page
- Using system date format
- Get post by tag
- Related Posts function not working
- the_content() Not Grabbing All Content
- Restrict displaying posts to the poster itself (in Back-end)
- How can I set a maximum allowed post size and number of posts submitted?
- Change Author Name to Sitename on Frontend
- Exclude a category of posts in author template
- saving/reading custom field value does not work – no value gets POSTed
- Author Avatar as default first image
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Have h2 tag not show up if there are no blog posts
- how can authors to define custom pages?
- Send email to admin with post author
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Prevent 404 of Author pages without posts
- How to implement a WordPress comments function?
- How to add content above footer in posts from specific category
- shortcode // get posts by ids
- Find most used words in post titles
- $post->post_content empty while all other properties are correct
- Display post by Random Authors on Page Refresh
- What permissions does a role need for the user to be assigned as the author of a post?
- AJAX load more posts not using correct category and repeating the same few posts
- How to correctly escape data
- Display author bio box
- Check if user has avatar
- Run function after post is updated
- When Author add new post change default status to pending
- fire action when post is being edited as well as saved?
- Create a Page Template Which Displays All Posts by Current User
- Set the limit to allow author when make post!
- Getting rid of the blog page entirely
- How to get single post by one author?
- List direct children of page
- save_post not working
- Display a custom field rating system in the front end
- wp trim function not working
- Echo author slug in post edit page
- Ajax calls in wordpress
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- How to make the Post Author name fixed as “Editorial Staff” even if there are multiple authors?
- How to sort posts alphabetically based on a specific parent category