PHP question - help!

  • Started
  • Last post
  • 3 Responses
  • Claymantis

    I'm using a WordPress plugin that creates a verification email. Each email has a unique link that creates the account.

    verify_email=d2527cc7a0713fdd5fd...

    However, I dont want to use this plugin.

    im using send grid now to implement their API in the registration process. The api works and the emails are sending but it just sends a static link, which fails to create the account. How can I make the api or php make that dynamic link for each unique account creation because right now, if you click on the link , it takes you to the welcome screen but doesn't actually create the account because its not making a the passing the values of the account creation?

    This is the API....

    // SendGrid
    require_once dirname(__FILE__) . '/sendgrid/vendor/autoload.php';
    require_once dirname(__FILE__) . '/sendgrid/lib/SendGrid.php';
    require_once dirname(__FILE__) . '/sendgrid/lib/DotEnv.php';
    $sendgrid_apikey = "SG.woAWQZz-Tmq1samvA8IaLQ.2hRow...
    $sendgrid = new SendGrid($sendgrid_apikey);
    $url = 'https://api.sendgrid.com/';

    $template_id = '0cf2518f-b36d-4f1a-81d3-dada572...
    $js = array( 'sub' => array('%first_name%' => array($_REQUEST['first_name']), '%last_name%' => array($_REQUEST['last_name']), '%link%' => array("https://xxx.com/authorize... 'filters' => array('templates' => array('settings' => array('enable' => 1, 'template_id' => $template_id))));
    //echo json_encode($js);
    $params = array(
    'to' => $_REQUEST['email'],
    'toname' => $_REQUEST['first_name'] . " " . $_REQUEST['last_name'],
    'from' => ,
    'fromname' => "Weetend",
    'subject' => "xxx Account Verification",
    'text' => "Template",
    'html' => "",
    'x-smtpapi' => json_encode($js),
    );

    $request = $url.'api/mail.send.json';
    $session = curl_init($request);
    curl_setopt($session, CURLOPT_SSLVERSION, "https://www.howsmyssl.com/a/che...
    curl_setopt($session, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $sendgrid_apikey));
    curl_setopt($session, CURLOPT_POST, true);
    curl_setopt($session, CURLOPT_POSTFIELDS, $params);
    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($session);
    print_r($response);
    curl_close($session);
    // SendGrid

  • Claymantis0

    This is what the plugin uses (i think) to make the verification unique.

    <?php
    /*
    * Email verify customisation
    */

    add_filter( 'dw_verify_email_template_path', 'weetend_dw_verify_email_template_path' );
    function weetend_dw_verify_email_template_path( $template ){
    $template = get_template_directory() . '/tpl/emails/verify.php';
    return $template;
    }

    add_filter( 'dw_verify_email_template_args', 'weetend_dw_verify_email_template_args' );
    function weetend_dw_verify_email_template_args( $args ){

    $url = parse_url( $args['link'] );
    wp_parse_str( $url['query'], $str_result );

    $user_id = $str_result['user_id'];

    $user = get_user_by( 'id', $user_id );

    $args['first_name'] = $user->first_name;
    $args['last_name'] = $user->last_name;

    return $args;
    }

  • sted0
  • Claymantis0

    I really have no idea what im doing lol.

    I thought it would be easy to drop the API into the registration.
    Anyway you can explain what in need to do step by step?

    Thanks, Sted. If not its okay, might be to complex.