This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Use group module - in my own custom module

I am using the Group module, and are developing a custom module from where I need to programmatically add and remove users from groups.

I have been trying to do the following (should be fairly simple from what I can understand) 

$group = \Drupal\group\Entity\Group::load($gid);
$user = \Drupal\user\Entity\User::load($uid);
$group->addMember($user);

But when I run this code, I get an error:

Run a script in the background that IS NOT CRON

I have some scripts that I need to run manually, these scripts are not meant to be ran on a regular schedule, therefore, I DO NOT want to use cron. With that, how can I kick off a php script in the background?

I've tried to use `exec` but it doesn't know what drush is, so I can't run my script that needs ran via drush.
I looked into the `Background Process` module but 1) it hasn't been updated in years and 2) it doesn't have a Drupal 8 version. 

How can I run a script in the background that isn't done through cron?

Tutorial: Custom Block Visibility Plugins and the Condition Plugin API

I've created a tutorial on creating custom block visibility plugins, shown in the vertical tabs on block configuration pages. The tutorial can be seen here: https://www.jaypan.com/tutorial/custom-block-visibility-plugins-and-cond...

Multivalued field as a relationship

Is it impossible to use a Multivalued entity referenced field to be used as relationships?

For example, if I have a field with 'Allowed number of values' = 2, and I want to have a view with a relationship to each one of the field values.

Can I do that or is it not possible currently?

CallBack with Numeric field

In the callback I assign a number to an integer numeric field, it works because it displays it. When I save the movement the number is not saved.
I did various tests but didn't understand why you don't save it
The field is field_nu_hour_mission (integer)
If I write the number from Tstiera it displays it and stores it

Status of comments

Hello,

I have some checkboxes instead written text comments. One group with some rules create content, second group can add comments with (status). And third group should be able change status of these comments only. I need set one field which can be modify by other users.

Example.

I will create content, friend will create 5 comments in my content with statuses "not solved". My next friend change these statuses to "solved".

Is that possible do with drupal?

BR

Roman

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions