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
- How to change the case of all post titles to “Title Case”
- How to detect single.php (but not single-portfolio.php)?
- Function to execute when a post is moved to trash .
- Changing the post date and time with function
- Get current post id in functions.php
- Hook that get’s triggered when the author of a post is changed
- Dynamically add id to heading tags
- the_author() returns empty string
- Prevent Authors from viewing each others Posts
- Display Random Author with Details in Sidebar
- disable WP automatically inserted line breaks after an image
- How to show list of posts by author and category?
- Getting the post_id in wp_ajax function
- Fatal error: Call to undefined function post_exists()
- WordPress: How to get the current logged in author page URL?
- How to publish a post with empty title and empty content?
- How to add editor’s name to entry meta byline?
- Different permalink for posts and authors
- delete post also attachments
- 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?
- Restrict users from editing post based on the age of the post
- Query posts distinct authors
- 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
- Get the user type of an author
- Code to auto expire posts after 30 days
- Show the title of the latest post by author
- List only child categories a post is in, of a specific parent category
- Find most recent authors
- Keep a fluid max number of posts on site
- Show author post count in sidebar – Variable
- Get current users post URL?
- Get the author of the latest revision
- Filter posts by author and category simultaneously
- How to change post status from publish to draft using hook in wordpress?
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Custom colors for post rows based on post meta value
- How to add an admin function only to posts, not pages?
- Human Time Diff, change mins to minutes
- Post author is changed to admin after his post is modified by admin
- How to get new post URL?
- Force update all posts in custom post type, no content changes
- Custom wp_trim_words() function not trimming right
- Disable REST API for a user ROLE
- How to display post tags
- How to Display Post View Count
- Get all posts by post_author
- Remove double space after a period
- Add confirmation popup on “Move to Trash”
- Allow role to delete posts but block him the wp-admin
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- WP_Query in functions.php overrides global $post object, even with wp_reset_query()
- Delete Post From Front-End and attachment permanently
- How can I control multiple editing of wordpress posts?
- Limit function to specific post category
- Multiple authors for single post without plugin
- Limit number of posts a user can make per minute?
- $post object is null
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Authors in menu, template list post by author
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Author must complete profile info before they can publish a post?
- Function to show random posts from a category
- WP rest api returns 404 only when author param is used
- How to change the page break URL from ../post/2 to …/post/page2/
- Hiding posts in a list from specified categories
- Disable single post page
- Enabling post thumbnails for custom post type
- Run a function when post is deleted?
- Checking is user author of number of posts?
- Create cron job without a plugin?
- Getting current post ID in functions.php
- How to rename “Publish” metabox title in post screen
- How can I show wordpress posts based on author?
- Action hook for new pending posts?
- Show info to author only
- Uppercase first sentence in every post
- Add icon/badge next to posttitle of specific category
- Ajax posts filter by date, comments, top views, top likes
- Auto “expire” all of an authors posts on spcific date
- Prepend or add an Image to the content of a Post
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- How to get the user meta data for a post?
- Why content_arr[‘extended’] removes paragraph tags?
- Limit posts per author role (excluding admin) in home page
- Guest Author – How to display posts on /author/ archive page
- 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
- How to display the link (title) and thumbnail post?