New Member Auto Message

Im trying to add an auto message to the profile_activate.php file in the PageCompPageMainCode method but it doesnt seem to be working.

 

This is the code block im trying to use.

 

 $sMessageBody = 'Enter body here';
   
    $sMessageSubject = 'Enter subject here';
   
    $sQuery =
    "
    INSERT INTO
    `sys_messages`
    SET
    `Sender`       = '2',
    `Recipient`    = '$ID',
    `Subject`      =  '{$sMessageSubject}',
    `Text`         =  '{$sMessageBody}',
    `Date`         = NOW(),
    `New`          = '1',
    `Type`         = 'letter'
    ";

 

Any ideas on why this isnt sending a message to a member when they join?

Thanks

Dustin

Quote · 24 Sep 2013

try:

$sQuery = mysql_query("INSERT INTO `sys_messages` (`Sender`,  `Recipient`, `Subject`,  `Text`,  `Date`,  `New`,  `Type`) VALUES ( '2', '$ID',  '$sMessageSubject',  '$sMessageBody', NOW(), '1', 'letter')");

caredesign.net
Quote · 24 Sep 2013

Thanks, it seems its not running that main function at all, I put in a print and exit function and the page didnt print out the query and exit?

Im using auto activate, does this mean it loads a different function?

Thanks

Dustin

Quote · 24 Sep 2013

without seeing the whole code, I have no clue. I just noticed that you were using an update sql query (SET) for an insert sql query. If you can, post the whole code that you are using and someone should be able to help out.

caredesign.net
Quote · 24 Sep 2013

 

update sql query (SET) for an insert sql query.


Just so you know. SET can be used with a insert. And dolphin actually does this quite often. It in many cases is easier then the longer normal insert method.



https://www.deanbassett.com
Quote · 24 Sep 2013

thats three new things I have learned today from you Deanos. I have been using the long way for so long I did not realize it could be done with the SET. Thank You for your education.

caredesign.net
Quote · 24 Sep 2013

I will post the code below, but here is the thing.

I dont think its calling the file profile_activate.php at all when a user joins.

If you click here - http://countrylinked.com.au/profile_activate.php

You will see what I mean.

But when you join, it signs up the user as per normal which makes me believe its not even running this page.

Is it because I have it set to auto confirm and activate?

If so what page do I try and run this query?

PROFILE_ACTIVATE.PHP

<?php
print "Hello world!";
exit();

/**
 * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
 * CC-BY License - http://creativecommons.org/licenses/by/3.0/
 */

require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolEmailTemplates.php' );

// --------------- page variables

$_page['name_index'] = 40;

$ID = bx_get('ConfID');
$ConfCode = bx_get('ConfCode');

if (!$ID && !$ConfCode)
    exit;

$logged['member']    = member_auth(0, false);

$_page['header'] = _t("_Email confirmation");
$_page['header_text'] = _t("_Email confirmation Ex");

// --------------- page components

$_ni = $_page['name_index'];
$_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode($ID, $ConfCode);

// --------------- [END] page components

PageCode();

// --------------- page components functions

/**
 * page code function
 */
function PageCompPageMainCode($iID, $sConfCode)
{
    global $site;

    $ID = (int)$iID;
    $ConfCode = clear_xss($sConfCode);
    $p_arr = getProfileInfo($ID);
  
    $sMessageBody = 'PUT MESSAGE HERE';
   
    $sMessageSubject = 'PUT SUBJECT HERE';
   
    $sQuery = "INSERT INTO `sys_messages` (`Sender`,  `Recipient`, `Subject`,  `Text`,  `Date`,  `New`,  `Type`) VALUES ( '2', '$ID',  '$sMessageSubject',  '$sMessageBody', NOW(), '1', 'letter')";
    print $sQuery;
    exit();
   
   
    $result = db_res($sQuery);

    if (!$p_arr) {
        $_page['header'] = _t("_Error");
        $_page['header_text'] = _t("_Profile Not found");
        return MsgBox(_t('_Profile Not found Ex'));
    }

    $aCode = array(
        'message_status' => '',
        'message_info' => '',
        'bx_if:form' => array(
            'condition' => false,
            'content' => array(
                'form' => ''
            )
        ),
        'bx_if:next' => array(
            'condtion' => false,
            'content' => array(
                'next_url' => '',
            )
        )
    );

    if ($p_arr['Status'] == 'Unconfirmed') {
        $ConfCodeReal = base64_encode( base64_encode( crypt( $p_arr[Email], CRYPT_EXT_DES ? "secret_co" : "se" ) ) );
        if (strcmp($ConfCode, $ConfCodeReal) != 0) {
            $aForm = array(
                'form_attrs' => array (
                    'action' =>  BX_DOL_URL_ROOT . 'profile_activate.php',
                    'method' => 'post',
                    'name' => 'form_change_status'
                ),

                'inputs' => array(
                    'conf_id' => array (
                        'type'     => 'hidden',
                        'name'     => 'ConfID',
                        'value'    => $ID,
                    ),
                    'conf_code' => array (
                        'type'     => 'text',
                        'name'     => 'ConfCode',
                        'value'    => '',
                        'caption'  => _t("_Confirmation code")
                    ),
                    'submit' => array (
                        'type'     => 'submit',
                        'name'     => 'submit',
                        'value'    => _t("_Submit"),
                    ),
                ),
            );
            $oForm = new BxTemplFormView($aForm);
            $aCode['message_status'] = _t("_Profile activation failed");
            $aCode['message_info'] = _t("_EMAIL_CONF_FAILED_EX");
            $aCode['bx_if:form']['condition'] = true;
            $aCode['bx_if:form']['content']['form'] = $oForm->getCode();
        } else {
            $aCode['bx_if:next']['condition'] = true;
            $aCode['bx_if:next']['content']['next_url'] = BX_DOL_URL_ROOT . 'member.php';

            if (getParam('autoApproval_ifJoin') == 'on' && !(getParam('sys_dnsbl_enable') && 'approval' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join'))) {
                $status = 'Active';
                $rEmailTemplate = new BxDolEmailTemplates();
                $aTemplate = $rEmailTemplate -> getTemplate( 't_Activation' ) ;

                sendMail( $p_arr['Email'], $aTemplate['Subject'], $aTemplate['Body'], $p_arr['ID'], array(), 'html', false, true );
                $aCode['message_info'] = _t( "_PROFILE_CONFIRM" );
            } else {
                $status = 'Approval';
                $aCode['message_info'] = _t("_EMAIL_CONF_SUCCEEDED", $site['title']);
            }

            $update = db_res( "UPDATE `Profiles` SET `Status` = '$status' WHERE `ID` = '$ID';" );
            createUserDataFile( $ID );
            reparseObjTags( 'profile', $ID );
           

            // Promotional membership
            if (getParam('enable_promotion_membership') == 'on') {
                $memership_days = getParam('promotion_membership_days');
                setMembership( $p_arr['ID'], MEMBERSHIP_ID_PROMOTION, $memership_days, true );
            }

            // check couple profile;
            if ($p_arr['Couple']) {
                $update = db_res( "UPDATE `Profiles` SET `Status` = '$status' WHERE `ID` = '{$p_arr['Couple']}';" );
                createUserDataFile($p_arr['Couple']);
                reparseObjTags('profile', $p_arr['Couple']);

                //Promotional membership
                if (getParam('enable_promotion_membership') == 'on') {
                    $memership_days = getParam('promotion_membership_days');
                    setMembership( $p_arr['Couple'], MEMBERSHIP_ID_PROMOTION, $memership_days, true );
                    if ($p_arr['Sex'] == 'male') {
                            setMembership( $p_arr['ID'], FEMALE_MEMBERSHIP_ID, 7, true );
                    } elseif ($p_arr['Sex'] == 'female') {
                        setMembership( $p_arr['ID'], FEMALE_MEMBERSHIP_ID, 8, true );
                    }
                }
            }
            if (getParam('newusernotify')) {
                $oEmailTemplates = new BxDolEmailTemplates();
                $aTemplate = $oEmailTemplates->getTemplate('t_UserConfirmed');

                sendMail($site['email_notify'], $aTemplate['Subject'], $aTemplate['Body'], $p_arr['ID']);
            }
        }
    } else
        $aCode['message_info'] = _t('_ALREADY_ACTIVATED');
    return $GLOBALS['oSysTemplate']->parseHtmlByName('profile_activate.html', $aCode);
}

Quote · 25 Sep 2013

I have been playing around with this to try and see what I can figure out. I have set my test site to auto activate as you have. If you look on the page you are referencing there is the section that sends an email once a user has successfully created their account and it has been activated. So that tells me the page is being used. I think the issue may be WHERE to put your code and i have been trying to put it in different places, but so far it is not working for me either. Will let you know if I manage to accomplish what you are trying to get.

caredesign.net
Quote · 25 Sep 2013

 

I have been playing around with this to try and see what I can figure out. I have set my test site to auto activate as you have. If you look on the page you are referencing there is the section that sends an email once a user has successfully created their account and it has been activated. So that tells me the page is being used. I think the issue may be WHERE to put your code and i have been trying to put it in different places, but so far it is not working for me either. Will let you know if I manage to accomplish what you are trying to get.

 Awesome, thank you very much, I will continue to test as well and try what you suggested.

Quote · 25 Sep 2013

I GOT IT!!!!!!!!!!!!!

well, it works for me. I know deanos pointed out that you can use the set like you have, but I have been taught the long way, and I managed to get it to work. This is what I did:

inc/classes/BxDolJoinProcessor.php (make a backup of this page before making any changes)

look for:

    function showFinishPage( $iMemID, $sStatus )
    {
        switch( $sStatus ) {
            case 'Active':      $sStatusText = ('_USER_ACTIVATION_SUCCEEDED'); break; //activated automatically
            case 'Approval':    $sStatusText = ('_USER_CONF_SUCCEEDED');       break; //automatically confirmed
            case 'Unconfirmed': $sStatusText = ('_EMAIL_CONF_SENT');           break; //conf mail succesfully sent
            case 'NotSent':     $sStatusText = ('_EMAIL_CONF_NOT_SENT');       break; //failed to send conf mail
        }

 

and add this underneath it:


                                                         $sMessageBody = 'Enter body here';
                       $sMessageSubject = 'Enter subject here';
            $sQuery = mysql_query("INSERT INTO `sys_messages` (`Sender`, `Recipient`, `Subject`, `Text`, `Date`, `New`, `Type`) VALUES ('1', '$iMemID', '$sMessageSubject', '$sMessageBody', NOW(), '1', 'letter')");

 

EDIT: in your code for the Sender entry, you had a 2, I changed it to a 1 because my admin account has a user ID of 1(highlighted in red)

message after joining.png · 623.5K · 147 views
caredesign.net
Quote · 25 Sep 2013

IT WORKS!!!!!!!!

Thank you very much, I didnt even think of looking in the classes.

Thanks.

Dustin

Quote · 25 Sep 2013

I am just glad to be able to provide some sort of help, considering the amount of help I have gotten here. I am not always correct, but if it gets you in the right direction, I am happy. Glad to see it is working for you.

caredesign.net
Quote · 25 Sep 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.