Skip to content
Permalink
Browse files

feat: add optional newsletter

  • Loading branch information...
themightychris committed Jun 18, 2019
1 parent 94b9e5c commit 9cd30cd1d2565aad5e28a2c4db94fe6237e77c40
@@ -79,6 +79,11 @@
{field inputName="FirstName" label="First Name" type="text" default=$User->FirstName}
{field inputName="LastName" label="Last Name" type="text" default=$User->LastName}
{field inputName="Email" label="Email" type="email" default=$User->Email}

{if Laddr\ProfileRequestHandler::$enableNewsletterOptIn}
{checkbox inputName="Newsletter" value="1" unsetValue="0" label="Subscribe to Newsletter" default=$User->Newsletter}
{/if}

{field inputName="Phone" label="Phone" type="tel" default=$User->Phone}
{field inputName="Twitter" label="Twitter" type="text" default=$User->Twitter}

@@ -0,0 +1,20 @@
<?php
namespace Laddr;
class ProfileRequestHandler extends \ProfileRequestHandler
{
/**
* True to enable opting into newsletter
*/
public static $enableNewsletterOptIn = false;
public static function __classLoaded()
{
if (static::$enableNewsletterOptIn
&& !in_array('Newsletter', static::$profileFields)
) {
static::$profileFields[] = 'Newsletter';
}
}
}
@@ -0,0 +1,8 @@
<?php
use Emergence\People\User;
User::$fields['Newsletter'] = [
'type' => 'boolean',
'default' => true
];
@@ -0,0 +1,4 @@
<?php
// uncomment to enable newsletter opt-in/out option in user profiles
// Laddr\ProfileRequestHandler::$enableNewsletterOptIn = true;
@@ -0,0 +1,3 @@
<?php
Laddr\ProfileRequestHandler::handleRequest();

0 comments on commit 9cd30cd

Please sign in to comment.
You can’t perform that action at this time.