Drupal Code: Fetch Link, Title, Category names, tag names from every article
See the code below: The output will be 4 columns separated by comma. You can…
March 25, 2018
Many times, while administering your drupal website, you must have encountered some spam emails. And, you have no way to contact the users. You might want to block the user.
Drupal provides a way to block a user by login from an admin user. But, if you have many users, it will take considerable amount of time to do it one by one.
Drupal provides an api: user_save(), which takes a loaded user object. And, it can save user in its database.
foreach($mails as $ml) { $user = userloadbymail($ml); if (isset($user) && $user->status == 1) { $uObj = new stdClass(); $uObj->uid = $user->uid; usersave($uObj, array(‘status’ => 0)); print “User blocked: “.$user->mail; } print “\n”; }
<h3>Understanding Code</h3>
First, I load user by email by using api: <strong>user_load_by_mail()</strong>. Then, I prepare an object by using user uid, and set its status as 0. In drupal, user status of 1 is considered active user.
The API: user_save() is taking 2 parameters. Since, I want to update user. I just passed the object with its uid set. And, in 2nd parameter, I pass the array of attributes I want to update. This ensures, that I do not set any other parameter accidently.
And, it blocks all the user mails passed.
See the code below: The output will be 4 columns separated by comma. You can…
This is regarding the timeit implementation in python. The basic requirement…
Introduction In our previous post How to configure Grafana on docker, we saw how…
Static websites have several advantages over dyanamic websites. If you are…
I was using On page optimization of the article pages, and found that meta…
Thanks for reading.
In this post, we will see some of the frequently used concepts/vocabulary in…
System design interview is pretty common these days, specially if you are having…
Introduction You are given an array of integers with size N, and a number K…
Graph Topological Sorting This is a well known problem in graph world…
Problem Statement Given a Binary tree, print out nodes in level order traversal…
Problem Statement Given an array nums of n integers and an integer target, are…