Paypal Payment Issue While Validating Payment - Access Denied
Introduction I was using Paypal payment on one of my website, and suddenly lot…
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 = user_load_by_mail($ml); if (isset($user) && $user->status == 1) { $uObj = new stdClass(); $uObj->uid = $user->uid; user_save($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.
Introduction I was using Paypal payment on one of my website, and suddenly lot…
Introduction VS code is an excellent free IDE for maany types of programming…
Introduction Consider a scenario where you are building a docker image on your…
Introduction to problem This post is applicable for those who has already an SSL…
Youtube APIs are great way to fetch details about video or channels. I’ve…
Introduction You have a running kubernetes setup, and have a webservice (exposed…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…