Skip to content

Commit ab7207e

Browse files
committed
add message placeholder
1 parent c21e5d8 commit ab7207e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
4. Select `user` template, add `mobile_phone` field and press `Save` - see [screenshot](_screenshots/edit_user_template.png)
1010
5. Go to `Admin->Modules->Sms77`, enter your `API Key` and press `Submit`
1111

12-
### Support
12+
### Placeholders
13+
14+
- email
15+
16+
Usage: `{{email}}` resolves to the users email address
17+
18+
#### Support
1319

1420
Need help? Feel free to [contact us](https://www.sms77.io/en/company/contact/).
1521

src/Sms77.module

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class Sms77 extends WireData implements Module, ConfigurableModule {
107107
'singular' => true,
108108
'summary' => 'Send SMS via Sms77.io.',
109109
'title' => 'Sms77',
110-
'version' => 100,
110+
'version' => 110,
111111
);
112112
}
113113

@@ -143,6 +143,9 @@ class Sms77 extends WireData implements Module, ConfigurableModule {
143143
$to = $e->data['object']['user']->data['mobile_phone'];
144144
$from = $this->sms_from;
145145

146+
foreach (array('email') as $key) $text = str_replace(
147+
'{{' . $key . '}}', $e->data['object']['user']->data[$key], $text);
148+
146149
$this->sms(compact('from', 'text', 'to'));
147150

148151
$this->wire->session->redirect($page->editUrl);
@@ -153,6 +156,8 @@ class Sms77 extends WireData implements Module, ConfigurableModule {
153156
}
154157

155158
private function post($endpoint, array $payload) {
159+
$text = $payload['text'];
160+
156161
if ('' === $this->apiKey) {
157162
$e = $this->_('Not sending: Missing API key!');
158163
$this->wire->log->error($e, true);

0 commit comments

Comments
 (0)