Contrary to the description in the content-type settings page,

If enabled, users will be allowed to register for this content type unless an administrator disables registrations on specific posts.

I noticed that turning on registrations for a given content type did not automatically turn registration on for new types, requiring an administrator to manually turn enable registration for each new node. Obviously this is less than ideal.

After working on the problem off and on I realized that the root of the problem is that creating a new (registration enabled) node did not create an entry in the registration_node table, much less one that had 'status' enabled.

I'm still new to hacking around in drupal, but the solution I came up with was to implement hook_node_insert() and create an entry in the table for nodes that are enabled for registration, with 'status' turned on. Code follows:

/**
 * Implements hook_node_insert().
 */
function registration_node_insert($node) {
  if (variable_get('registration_node_status_' . $node->type, 0)) {  
    $settings = array(
      'multiple_registrations' => 0,
      'from address' => variable_get('site_mail', ini_get('sendmail_from')),
    );
    
    $fields = array(
      'nid' => $node->nid,
      'status' => 1,
      'capacity' => 0,
      'send_reminder' => 0,
      'settings' => serialize($settings),
    );
    
    db_insert('registration_node')
      ->fields($fields)
      ->execute();
  } 
}

I grabbed the array structures and most of the default values from registration.forms.inc, with the one change of setting 'status' to equal 1 by default. This now appears to be working as intended, as new nodes of the right types provide the user the "register" tab as soon as created. There may be a better or more comprehensive way to do this, so please let me know if so. Hopefully either this solution or a better one can be incorporated into the main code.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

seanberto’s picture

Category: bug » feature
danweasel’s picture

If this isn't a bug report, then the text from structure/content types needs to be changed: "If enabled, users will be allowed to register for this content type unless an administrator disables registrations on specific posts."

That implies to me that new nodes should have registration enabled by default unless specifically turned off.

Currently, new nodes (that have registration bundles per their content type) have registration disabled by default unless specifically turned on.

So either the help text is incorrect or the behavior is. I mean, I think the above functionality needs to be there regardless, I'm just trying to clarify what kind of issue this is.

kclarkson’s picture

I second @danweasel Please add !!!

This will be a huge benefit for us who are trying to workout the kinks on this module.

Especially when using Devel Generate or moving from the Signup Module. I found out about this from the COD update posted a couple of days ago.

kclarkson’s picture

@danweasel

Just wanted to let you know that I copied and pasted your code into the file and the "enable" registration checkbox is still not checked by default.

Thanks,

danweasel’s picture

The module has been updated since I wrote this code, so no guarantee it works anymore, since I assume/hope levelos and co. are working on fixing this functionality.

I'll try checking out the new version and see if anything has changed on this issue and if this temporary fix can be updated until it's solved.

BTMash’s picture

Wanted to iterate on this post that the issue is not yet resolved. A simple resolution would be to integrate with rules and provide default rules that will do this for you.

seanberto’s picture

BTMash, we do have rules integration. If you want explore the rules approach, it'd be rad if you wanted to share your recipe.

BTMash’s picture

Hmm, with the rules integration, the way I see the rule should be set up is: if content has field 'blah' set, then action 'enable registration' should run. Right now, the rules integration is around if a registration was saved / viewed / etc. So the registration has to be enabled for any other rules to be able to fire off and thus kinda in reverse of what this asks (atleast...as far as I see).

mjross’s picture

Version: 7.x-1.x-dev » 7.x-1.0-alpha3
FileSize
902 bytes

Here is a patch that works with the current state of the Entity Registrations code.

[Edit: The comment number in the filename should have been 1357280. Apparently comment editing does not allow one to change the file attached to a comment.]

dpi’s picture

I think we are going for something more customizable by admins: #1430870: Automatically Create Registration Settings when Entities are Created.

levelos’s picture

Status: Needs review » Closed (won't fix)
Phix500’s picture

Component: Code » Registration Core

Please be gentle, I'm still sort of new to Drupal. Actually, I don't
care. I can take it:)
I installed the Entity Registration module and followed the instructions.
When I create an event, registrations are not only disabled by default,
but that is the only option that is listed in the drop down list.

Is there something I missed? I've revisited the process a number of
times. I guess my only option at this point is to go into the PHP and try
to find a fix that way.
I'm running Windows Server 2007 SP2
Drupal 7.23
Entity Registration 7.x.1.2
Thanks in advance, Phil Wetzel

Phix500’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.2
Component: Registration Core » Registration Entity Access
Category: feature » support
Status: Closed (won't fix) » Active

This always happens to me. The moment I finally give up and post a question -
I figure it out! Well, I'm still a bit confused, but I think I'm on the right track.
I misunderstood and thought that you create a content type for registrations,
but it has it's own type.

Also, I didn't notice the issue settings.
Thanks, Phil

Phix500’s picture

I'm still trying to get Event registrations cleaned up on my site. If I could only exchange a few emails or better yet have a 1/2 hour phone conversation with someone in the know, I think I'd be in great shape.

I have it working more less, but not ready for prime time. I think my greatest source of confusion is exactly what modules are used for the latest and greatest version of event registrations. In my searching, I have learned that this particular functionality has gone through a rather extensive evolution over time. If I'm not mistaken, the latest and greatest collection of modules required are Registration, Registration Entity Access, Registration Views, Registration Waitlist.
If I'm not mistaken Entity Registration, and EVA are not required. I think one of my problems is I still have one or both of those modules mixed in making things clunky.
I realize that the documentation for modules has to assume a certain level of Drupal knowledge, and my level of knowledge is maybe getting past beginner at this point. But, still the 2 pages I've found leave do little to clear my confusion. Maybe I'm asking for more idiot proofing like these modules are NOT required (EVA, Entity Registration) for instance in this case...I think.
I thank any replies in advance, and apologize in advance if there is a more relevant post somewhere. I'm going through the documentation once again. Phil

caxy4’s picture

Status: Active » Closed (won't fix)