Extension, Module

Archived
Forum
(read-only)


For official support, visit the official support site »

Invitations

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Yuri Salimovskiy

1 of 2
1
   

Batch generate and send Mail

Feature Request

PP
PP

It would be nice if the batch generate had on more field like send mail to each member.

So all members in the givne membergroup would receive a mail with x codes.
These members could use their mailed codes to invite new members.

Yuri Salimovskiy
# 1
Developer
Yuri Salimovskiy

I’ll consider implementing this

Yuri Salimovskiy
# 2
Developer
Yuri Salimovskiy

I’ll consider implementing this

PP
# 3
PP

Since this is not implemented yet.
Is there another way to give existing users codes to invite new users. I know there is a template tag to generate codes. But there seems to be very little control over the codes. I want every user to have only one code. Is there a way to do this?

Cheers,
Phil

Yuri Salimovskiy
# 4
Developer
Yuri Salimovskiy

Hi Phil,

here’s what you can do:

{exp:invitations:display mode="my"}
{if no_results}
{exp
:invitations:generate}
{
/if}
{
/exp:invitations:display} 

I hope the logic is clear - display generate tags only if there are no codes generated by this user

PP
# 5
PP

Great! Thank you.

PP
# 6
PP

I am using the code you suggested like this.
[code
{exp:invitations:display mode=“my” limit=“1”}
{if no_results}
  New Code: {exp:invitations:generate} – Copy and send to your friend.
{/if}
{if valid}
  <li class=“mainmenu invite”>
  Invite a new Artist</span>
  </li>
{/if}
{/exp:invitations:display}
]

When a unregistered user visits the site he gets an EE error saying he must be logged in.
I am using above code in my main navigaton so the error is on every i page.
The solution would be of course wrapping {if logged_in} around the invitations tag. But it is ignored by invitations!

Yuri Salimovskiy
# 7
Developer
Yuri Salimovskiy

You’re right - this looks like a bug. I’ll fix this in next release, meanwhile you can replace this code

function generate()
    
{
  
if ($this->EE->session->userdata('member_id')==0
  
{
   $this
->EE->output->show_user_error('general'lang('must_be_logged_in'));
  

with this

function generate()
    
{
  
if ($this->EE->session->userdata('member_id')==0
  
{
   
return $this->EE->TMPL->no_results();
  
PP
# 8
PP

Thanks,  it’s working now.

PP
# 9
PP

I’m sorry but I think I found another one.
I am using following code

{if logged_in_member_id <= "70"}
 {exp
:invitations:display mode="my" limit="1"}
  {if used}{
/if}
  {if valid}
   
<li class="mainmenu invite">
   <
span><a href="#">Invite a new Artist</a></span>
   </
li>
  
{/if}
  {if no_results}
   
<li class="mainmenu invite">
   <!-- 
{exp:invitations:generate} -->
   <
span><a href="#">Invite a new Artist.</a></span>
   <
li>
  
{/if}
 {
/exp:invitations:display}
{if
:else}
{
/if} 

My logged_in_member_id check works, and the link will not be shown. However {exp:invitations:generate} will still be executed and members with a member_id higher than 70 will generate codes.

Also when a member with a lower id than 70 visits the site,  {exp:invitations:generate} will be executed but the content of {if valid} will be shown instead of {if no_results}

Yuri Salimovskiy
# 10
Developer
Yuri Salimovskiy

It’s not a bug, it’s how conditionals in EE work. The code is parsed/executed in any case, {if..else} conditionals only determine what is getting displayed to user.
Try using switchee module or some advanced techniques (Low has some articles/advices about those)

PP
# 11
PP

OK, I see. I already tried exp:ifelse but it didn’t work. I will try switchee. Thanks for the tip

PP
# 12
PP

I still must be doing something wrong.
When I use ifelse no code is generated at all. When I remove ifelse codes are generated for everybody. Multiple times, even though my generate code is in no_results.

I tried to replace ifelse with switchee, but I don’t what variable I could use. I check for member_id < doesn’t work.

Yuri Salimovskiy
# 13
Developer
Yuri Salimovskiy

Hi Philip,

try adding some PHP to your templates (should be parsed on input)

<?php
if ($this->EE->session->userdata('member_id') <= 70{
?>
{exp
:invitations:generate}
<?php
}
?> 

see also this reference on EE parsing order http://loweblog.com/downloads/ee-parse-order.pdf

PP
# 14
PP

Hi,

I tried your php solution. It seems to be properly excluding the member_id > 70.
But still, there a multiple codes generated for users <70.

I am currently using s switchee solution. But it is acting the same as the php soltion. Multiple codes …

I cannot reproduce it. It is not on every pageload. Just sometimes.

PP
# 15
PP

Are your working on this one? I’m wondering because you didn’t answer.

1 of 2
1