Skip to:
Content
Pages
Categories
Search
Top
Bottom

Conditional mail to members

  • Avatar of martinbeaulne
    martinbeaulne
    Participant

    @martinbeaulne

    Hi ! I wrote a piece of code and I’ll like to have your thoughts about it.

    Basically, I want an automated script that checks if users have filled the field #2 of their profile. If they didn’t, I want the script to send a mail to them.

    As I don’t want to bother my members with 250 000 e-mails each if there is a loop problem in my code, I’d like to have your input about it before I use it.

    So, do you think the code is correct ?

    
    $mailcontent = "Hi ! You should fill the empty field !";
    <?php
    	while ( bp_members() ) : bp_the_member();
     		$value = xprofile_get_field_data('2')
    		if ( $value == "" ) {
    			$to = xprofile_get_field_data('4');
    			$subject = "I've got something to tell you";
    			$from = "Mywebsite@disney.com";
    			$headers = "From:" . $from;
    			mail ($to,$subject,$mailcontent,$headers);
    			echo "Mail sent to";
    			echo xprofile_get_field_data($name);
    		}
            
     
        	endwhile;
    ?>
    

    Thanks a lot for your help :)

You must be logged in to reply to this topic.