CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • WordPress Installations (Moderators: Kurund Jalmi, Coleman Watts) »
  • Require login for event registration / PHP error
Pages: [1]

Author Topic: Require login for event registration / PHP error  (Read 3613 times)

siriusly

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Wordpress 3.5.2
  • MySQL version: 5.1.56
  • PHP version: 5.2.17
Require login for event registration / PHP error
August 06, 2013, 04:31:56 pm
I am new to CiviCRM and would be most grateful for any help someone can provide here....

This is a two-part question:

1.  PRIMARY QUESTION:  How can I ensure that only a logged in user may register for an event??

I'm wondering how to require a user to be logged in in order to register for an event.   I've been able to display a custom message that for a first-time visitor to the registration page by modifying plugins/civicrm/CRM/Event/Form/Registration.php at line 253, but if a visitor is returning and not logged in, the message will not display (due to cookie?), and the user is allowed to continue with event registration.

Here's what I have there:

      // this is the first time we are hitting this, so check for permissions here
      if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId)) {
        CRM_Core_Error::statusBounce(ts('To register for this event, you need to log in to your member account. If you are not yet a member, you can <a href="http://*site-root/membership-join-page/">Join here</a> and then return to register. '), $infoUrl);
      }

2.  SECONDARY COMPLICATION:
If I use Wordpress Access Control to deny an Anonymous User permission to "register for events," the event registration form then returns this PHP error:

Warning: Cannot modify header information - headers already sent by (output started at /home/*user*/public_html/beta/wp-content/themes/TwentyEleven/header.php:5) in /home/*user*/public_html/beta/wp-content/plugins/civicrm/civicrm/CRM/Utils/System.php on line 349.

This happens regardless of theme and with all other plugins disabled.


Thank you!!!



siriusly

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Wordpress 3.5.2
  • MySQL version: 5.1.56
  • PHP version: 5.2.17
Re: Require login for event registration / PHP error
August 06, 2013, 11:30:15 pm
UPDATE to above post:

After a lot of experimentation, I hacked a solution to this, but it doesn't address the real problem, which seems to be a bug.  Here's what I did:

1. Disabled the registration form's check for login status by commenting out plugins/civicrm/CRM/Event/Form/Registration.php at line 253:
/*
      // this is the first time we are hitting this, so check for permissions here
      if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId)) {
        CRM_Core_Error::statusBounce(ts('To register for this event, you need to log in to your member account. If you are not yet a member, you can <a href="http://*site-root/membership-join-page/">Join here</a> and then return to register. '), $infoUrl);
      }
*/

2. Enabled event registration permissions for anonymous users, as well as members, in CiviCRM Wordpress Access Control settings. (PHP error still occurred if I didn't do this.)

3. Shifted the check for login status completely to Wordpress by installing the Restrict Content plugin — http://wordpress.org/plugins/restrict-content/ — and using its shortcode — [restrict][*CiviCRM registration form*][/restrict] — on the registration page.

4. Included instructions & links for non-logged in users to log in or create a membership account, along with a login widget.

And... it's working!

PS
I see that this bug was reported & closed because it couldn't be reproduced, but I will report it again.  It seems to occur with the combination of settings.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • WordPress Installations (Moderators: Kurund Jalmi, Coleman Watts) »
  • Require login for event registration / PHP error

This forum was archived on 2017-11-26.