How to get current logged in user comments drupal 7

drupal 8 get current user
drupal 8 dependency injection current user
drupal 8 get user id from entity
get current user role in drupal 8
container get current_user
get user role by uid drupal 8
drupal 8 twig current user
drupal 8 get user first name

I need to get current user comment details which is commented by him.

please try below code

global $user;
$query = db_select('comments', 'cm');
  $query->condition('cm.uid', $user->uid, '=');
  $result = $query->execute();
  while ($chunk = $result->fetchObject()) {
    print $chunk->subject; // comment title
print $chunk->nid; // on which node user enter comment
print $chunk->mail; // email of user

OR you can use view to create listing without using manual query. goto structure->views->create new view and select comments option in Show Field setting.

Thanks, Ankush

How do I get the current logged in user's UID?, Usecase example: - node type with user reference field - views for nodes with user reference field matching currently logged user. Log in or register to post comments Project: Content Construction Kit (CCK), » Views (for Drupal 7) I'd like to have an exposed filter on a user reference field to allow  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more . How to get current logged in user comments drupal 7. Ask Question Asked 2 years, 10 months ago. Active 1 year, 5 months ago. Viewed

You Can create a view (view page or view block) of comments and add the RELATIONSHIPS with user (Comment: Author) and add the CONTEXTUAL FILTERS for user (author User: Uid)

Allow to select "currently logged in user" as value on "User , $user = \Drupal::currentUser();. See the Drupal class. There are a lot of helper methods; most of them are shortcuts for services, so you don't have to call  To get all data in the user object, you need to do a full user_load(). The following is a first attempt at documenting the information that core puts into the object. Items with (?) are where I didn't know and took my best guess. If anyone knows more on this and can fill in the blanks, please leave a comment. I will at some point gather all the comments together into one and then file an issue

$view = new view();
$view->name = 'comments';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'comment';
$view->human_name = 'Comments';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Comments';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access comments';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'comment';
/* Relationship: Comment: Content */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['required'] = TRUE;
/* Relationship: Comment: Author */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'comment';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Field: Comment: Title */
$handler->display->display_options['fields']['subject']['id'] = 'subject';
$handler->display->display_options['fields']['subject']['table'] = 'comment';
$handler->display->display_options['fields']['subject']['field'] = 'subject';
$handler->display->display_options['fields']['subject']['label'] = '';
$handler->display->display_options['fields']['subject']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['subject']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Comment: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'comment';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: User: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Comment: Approved */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_node']['id'] = 'status_node';
$handler->display->display_options['filters']['status_node']['table'] = 'node';
$handler->display->display_options['filters']['status_node']['field'] = 'status';
$handler->display->display_options['filters']['status_node']['relationship'] = 'nid';
$handler->display->display_options['filters']['status_node']['value'] = 1;
$handler->display->display_options['filters']['status_node']['group'] = 1;
$handler->display->display_options['filters']['status_node']['expose']['operator'] = FALSE;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'comments';

How do I get the user ID for the currently logged-in user?, I need to get current user comment details which is commented by him. please try below code global $user; $query = db_select(  if user is logged in only. Ask Question Asked 5 years, 8 months ago. Active 5 years, 8 months ago. Viewed 751 times 0. I have a section of my drupal website that I only want displayed to users that are logged in. So if they click on "My Page" link and th

Create a view.

View cab get comments and you can add a filter to get only comments added by specific user, by passing (current) user id.

How to get current logged in user comments drupal 7, You will get a list of all users in the preview pane below for the moment. Let's start limit these results down to the currently logged in user: in contextual filters, use  Hello. Im using views to show content to users, but i need to show only the content to the current logged in user, i mean, the user can upload their content so i need to show that content of the current logged in user, i tried with arguments like:

It's not a standard function, but this gives the logged in user's comments. Get the nid from the node table w.r.t to user id.

I get the logged-in user comments without any theme:

$nid_result = db_select('node') -> fields('node', array('nid')) -> 
  condition('uid', $puser->uid, '=') -> 
  condition('type', 'user_profile_comment', '=') -> execute(); 
$nid = $nid_resul t-> fetchCol();

$user_detail = array(); 
$result = db_select('comment') -> fields('comment', array('cid')) -> 
  condition('nid', $nid[0], '=') -> orderBy('cid', 'DESC') -> execute(); 
$cids = $result->fetchCol(); 

Current User Contextual Filter and Relationship (Views) : drupal, In drupal 8 you can get current logged in users info by using currentUser() method. $currentAccount->id(); /To get User ID Add new comment; 3398 views Get node title from nid without using node_load($nid) in Drupal7. Hya. You want to (1) use the Views module to create the list – actually a list of users (rather than nodes/content). Then you want to (2) use relationships settings to add in the interests, and finally (3) add a contextual filter on "user: uid" with a default value fetched from the currently logged-in user.

How to get current user information programatically in drupal 8 , Drupal's comment framework provides a way for users to post comments on virtually any piece of to specify which types of users have the ability to create, delete, edit, or even view comments. By default, this is the currently logged-in user. User permissions for comments. To configure user permissions for commenting you must be logged in as either User 1 (the administrative user) or as a user with the "User: Adding fields to the comments for a content type. To add fields to the comment form for a given content type: Detailed comment documentation. When enabled, the Drupal comment

Pro Drupal 7 for Windows Developers, The currently logged in user should be able to see their profile information but at the same time they 0 comments comment They wanted to have a Drupal Views block which should display the profile of the current user. We can analyse the complexity of your Drupal 7 website and give you a report which will help you  If you want to get the current user from a controller use dependency injection: class MyController extends ControllerBase { /** * Drupal\Core\Session\AccountProxy definition.

[Drupal Views] How to display profile info of the current user in a View, I really don't need another username on a site that I am not going to have a public profile. Thanks to the Drupal Email Registration Module, we can offer our users a simple site emails, core comments, some node displays, some view displays, etc. any instance of username, with the email token field - [current-user:mail] I am trying to create a view page that user can list all nodes that they have voted on. This view will show the node title, the users vote, the average user vote and the number of votes. I created the view and it worked fine, except that all nodes are duplicated by the number of votes, because the “VotingAPI percent vote user” filter is not working correctly. I had a look at the SQL being

  • In user profile i need to show the comments of the user