There is an answer for your question right in the Codex:
The first parameter of get_comment
function is:
$comment – (integer) (required)
The ID of the comment you’d like to fetch. You must pass a variable
containing an integer (e.g. $id). A literal integer (e.g. 7) will
cause a fatal error (Only variables can be passed for reference or
Cannot pass parameter 1 by reference).Default: None
In your code, you’re passing a function result as this param, so it’s not a variable, so you get this error.
How to fix this? It’s pretty simple… Just use a variable in there:
$comment_id = get_comment_ID();
$user_id = get_comment( $comment_id )->user_id;
Or use a dummy variable (as shown in Codex):
$user_id = get_comment( $dummy = get_comment_ID() )->user_id;
Related Posts:
- Is there a way to use the WordPress users but without loading the entire WordPress core?
- Custom HTML structure in wp_list_categories
- How to protect own PHP code from WordPress updates
- 500 Internal server error after changing php version
- get_template_part not working with ajax
- Javascript code inside “” in core WordPress files .php
- How to display a value from a radio button in the options menu in wordpress
- Put php variable in shortcode
- Create Logout Link WordPress Admin Menu
- PHP in post content [closed]
- Display post image with fancybox
- Is there a WordPress version that is incompatible with PHP 5.3?
- WordPress 3.2 query_posts and pagination, permalinks issue
- Implement One Time URL Script
- Call to undefined function wp() in wp-blog-header.php
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- How to pass Select value from Javascript to PHP to generate select option on change
- Parse error: syntax error, unexpected ‘}’ surrounding a while
- Querying Database with wpdb
- Countdown to date function?
- php esc_html_e with an html link inside not working
- Is there a name for trivial WP PHP files like functions.php, archive php entry.php, page.php and so forth?
- show something only when user comes from specific page at remote host?
- Adding php script to WordPress [closed]
- Remove category from pagination
- Function Display article [closed]
- Custom Taxonomy Select Menu: Setting default option value?
- How to add author’s posts link (HTML + PHP) inside a function to output it
- Accidentally deleted php code in WordPress website [closed]
- How to load previous or next attachment with jquery ?
- How to get the second slug of a page url?
- custom add note meta box with add button in wordpress
- Display Sibling WooCommerce Product Categories on Archive Page
- duplicate posts with ajax load more wordpress
- Using ACF Relationship field to set post type to draft or published status
- Add custom HTML data to Contact Form 7 mail?
- Merge wp_get_post_terms
- Posts in two different columns Bootstrap
- Redirecting the lost password page request when using a custon login page
- WordPress load javascript file if something… (after the page is loaded)
- Running local copy of an old WordPress site on MAMP
- WordPress Shortcode based on other shortcode
- Customizing WooCommerce with PHP
- Force CSV download with template_redirect
- Undefined variable & issue with smof_data
- Form not working as it should in WordPress, but in a normal HTML site it does
- Pagination reset problem
- Use get_option with $emailTo on contact page
- Exclude Post ID from Array Specified in Custom Field
- Hide button based on PHP result
- Adding ID to a Listing but not inside WP_Query while
- How do I create a single WordPress page that will use PHP to include different HTML files based on a vaule in the URL?
- Why does a meta_query break this WP_Query?
- Create a custom page URL
- Forbid certain users to access a specific page
- Undefined variable notice [closed]
- Import js variables loaded via wp_localize_script() into js module without global scope connection
- Custom taxonomy with page post type – WordPress
- Alternative to php echo within code
- Add multiple HTML attributes to an Elementor button
- Customize the summary table of an order in the email
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- How to add Paragraph Tags in WordPress using Visual Composer?
- PHP – Multiple variables in insert post array
- advanced custom fields: repeater field within conditional statement [closed]
- please on skin.php on theme wordpress option fix on theme option to not print empty variables and empty
- How to cut a section of a URL from a string with a regular expression?
- Too few arguments at registering new templates in my plugin
- inner-wrap div pushing custom table far down on page
- Remove Woocommerce product from cart with ajax/fetch
- Automatically change insurance quantity based on cart total [closed]
- I want to lists posts in wordpress to nearest location entered by the user
- There’s a 0 adding to the value on multiple post type
- Add/alter image attribute before render
- How do I do so that people can register on my wordpress site?
- Custom taxonomy pagination shows 404
- Why does WordPress not send the user the email to add a password?
- How to put a class in the p tag automatically added by the_content() in the wordpress loop?
- How to sort custom sortable column by custom table value
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- WooCommerce Modal Fly cart on add to cart – With AJAX
- /page/2/ redirect to 404
- How can I trim /page/ URL with PHP in WordPress
- Adding date and time to the same request
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom nav with bootstrap dropdown
- Limit a search box by CPT + taxonomies, in only one page
- How to edit a widget code?
- Hide ‘Downloadable’ and ‘Virtual’ checkbox options from Woocommerce Variations?
- footer doesn’t display
- hiddenQuestions.find is not a function
- How can I improve and optimise my wordpress web server for better performance in 2023
- Internal server error when enabling Multisite in WordPress
- duplicating page templates
- Upload multiple files via ajax from an HTML file input
- How to pass javascript var to php var
- running an existing WordPress site from Visual Studio Code?
- get_post_meta returns on side but it doesn’t return on bottom of admin page