0

The site I am working on gives new members the opportunity to download an original .mp3 (no licensing or copyright issue here), so on the confirmation email, I put a direct link to the file. However, when that link is clicked, the user is redirected to the 404 error page. The file is located at 'http://www.playpromedia.com/assets/artists/music/The_Armory_Hands_Up_D-Phi-E_Remix.mp3' and I checked via FTP and the file is definitely there. When I click that link in a webpage, the song plays and can be downloaded. But when the link is clicked in the email, 404!!! Here's my registration/confirmation code. Any help is appreciated.

<?php

// Exit if accessed directly
if ( !defined('ABSPATH')) exit;

/*
Template Name: Register Page
*/

require_once(ABSPATH . WPINC . '/user.php');  
global $wpdb, $user_ID;

get_header();
?>

<style>td{ border:none; }</style>

<?php
if (!$user_ID) {
   if(get_option('users_can_register')) { 
       if($_POST){
           $role = $wpdb->escape($_REQUEST['role']);
           $username = $wpdb->escape($_REQUEST['username']);
           $password = $wpdb->escape($_REQUEST['passwrd']);
           $email = $wpdb->escape($_REQUEST['email']);
           $fname = $wpdb->escape($_REQUEST['fname']);
           $fname = $wpdb->escape($_REQUEST['fname']);
           $lname = $wpdb->escape($_REQUEST['lname']);
           $zipcode = $wpdb->escape($_REQUEST['zipcode']);
           $dob = $wpdb->escape($_REQUEST['DOB']);
           $school_name = $wpdb->escape($_REQUEST['school_name']);
           $band_name = $wpdb->escape($_REQUEST['band_name']);
           $band_url = $wpdb->escape($_REQUEST['band_url']);
           $url = $wpdb->escape($_REQUEST['band_url']);

           $new_id = wp_insert_user( array (
                'user_login' => $username,
                'user_pass' => $password,
                'user_email' => $email,
                'role' => $role,
                'first_name' => $fname,
                'last_name' => $lname,
                'user_url' => $url,
                'user_registered' => date('Y-m-d H:i:s')
           ) ) ;

           if ( is_wp_error($new_id) ){
               echo "Username already exists. Please try another one.";
           } else {
               update_user_meta($new_id, 'zip_code', $zipcode);
               update_user_meta($new_id, 'band_name', $band_name);
               update_user_meta($new_id, 'band_url', $band_url);
               update_user_meta($new_id, 'school_name', $school_name);
               update_user_meta($new_id, 'dob', $dob);

               $from = get_option('admin_email');
               $headers = 'From: '.$from . "\r\n";
               $subject = "Registration successful";
               $msg = "<html><head><title>Registration successful</title></head><body><p>Thank you for signing up for a FREE account with our online community. As a member you will be able to connect to our network of artists and music enthusiasts while gaining access to exclusive content and networking opportunities. You will also gain firsthand experience in the music industry by participating in PlayPro Media industry events and projects.</p><p>As a member you will find new music in areas around you. Active members will have access to free shows, music, prizes and Album credits. V.I.P and private parties will be available along with travel aboard the PlayPro Media tour bus. Our community allows for communication among concert goers and bloggers across the nation to discuss upcoming concerts and events on our properties.</p><p>Start connecting with like-minded music lovers today!</p><p style='text-align:right;'>Play On,<br>PlayPro Media</p><br><p>To redeem your free download from PlayPro Media, right-click the link below and choose \"Save Target as..\" on Windows or \"Download Linked File\" on Mac OS X.</p><p><a href='http://www.playpromedia.com/assets/artists/music/The_Armory_Hands_Up_D-Phi-E_Remix.mp3'>DOWNLOAD SONG</a></p></body></html>";

               add_filter( 'wp_mail_content_type', 'set_html_content_type' );
               wp_mail( $email, $subject, $msg, $headers );
               remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
               echo(  "<p><b>Thank you</b> for signing up for a FREE account with our online community. As a member you will be able to connect to our network of artists and music enthusiasts while gaining access to exclusive content and networking opportunities. You will also gain firsthand experience in the music industry by participating in PlayPro Media industry events and projects.</p><p>Please check your email for further details and a link to your <b>FREE DOWNLOAD</b>. If you don't receive the email in a few minutes, please check your spam folder for the message.</p>" ); exit;
           } // end if
       } else { ?>

            <h1 style="color:#F87114;">Connect With PlayPro Media</h1>

            <div id="result"></div> <!-- To hold validation results -->

            <form id="frmRegister" action="" method="post" autocomplete="off" style="width:60%; margin: 0 auto;">
                <table cellpadding="0" cellspacing="0" width="100%" border="0" style="border:none;">
                    <tr>
                        <td style="width:30%;"><label>PPM Role</label></td>
                        <td style="width:70%;">
                            <select name="role" id="ppmRole" style="width: 200px;">
                                <option value="member">Member</option>
                                <option value="streetteam">Street Team</option>
                                <option value="artist">Artist</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Username</label></td>
                        <td style="width:70%;"><input type="text" id="username" name="username" class="text"  autocomplete="off" /><br><span style="font:italic 12px sans-serif; color:#F87114;"><b>NO SPACES ALLOWED. If you want to enter multiple words, separate each with a hypen (i.e., plucking-guitarist) or just use your email as your username.</b></span></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Password</label></td>
                        <td style="width:70%;"><input type="password" id="passwrd" name="passwrd" class="text"  autocomplete="off" /></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Confirm Password</label></td>
                        <td style="width:70%;"><input type="password" id="passwrd2" name="passwrd2" class="text"  autocomplete="off" /></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Email Address</label></td>
                        <td style="width:70%;"><input type="text" id="email" name="email" class="text"  autocomplete="off" /></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>First Name</label></td>
                        <td style="width:70%;"><input type="text" id="fname" name="fname" class="text"  autocomplete="off" /></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Last Name</label></td>
                        <td style="width:70%;"><input type="text" id="lname" name="lname" class="text"  autocomplete="off" /></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Phone</label></td>
                        <td style="width:70%;"><input type="text" id="phone" name="phone" class="text"  autocomplete="off" /><br><span style="font:italic 12px sans-serif; color:#F87114;"><b>Please enter only numbers (i.e., 5551234567)</b></span></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Zip Code</label></td>
                        <td style="width:70%;"><input type="text" id="zipcode" name="zipcode" class="text"  autocomplete="off" /></td>
                    </tr>
                    <tr>
                        <td style="width:30%;"><label>Date of Birth</label></td>
                        <td style="width:70%;"><input type="text" name="DOB" class="text"  autocomplete="off" /><br><span style="font:italic 12px sans-serif; color:#F87114;"><b>Please enter as YYYY-MM-DD</b></span></td>
                    </tr>
                    <tr class="steam" style="display:none;">
                        <td style="width:30%;"><label>Name of School</label></td>
                        <td style="width:70%;"><input type="text" name="school_name" class="text"  autocomplete="off" /><br><span style="font:italic 12px sans-serif; color:#F87114;"><b>Please enter None if you are not currently enrolled</b></span></td>
                    </tr>
                    <tr class="artie" style="display:none;">
                        <td style="width:30%;"><label>Artist/Band Name</label></td>
                        <td style="width:70%;"><input type="text" name="band_name" class="text"  autocomplete="off" /></td>
                    </tr>
                    <tr class="artie" style="display:none;">
                        <td style="width:30%;"><label>Artist/Band URL</label></td>
                        <td style="width:70%;"><input type="text" name="band_url" class="text"  autocomplete="off" /><br><span style="font:italic 12px sans-serif; color:#F87114;"><b>Please include the entire address including http://</b></span></td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr><td colspan="2">
                        <input type="submit" id="submitbtn" name="submit" value="Register Now" />
                    </td></tr>
                </table>
            </form>

            <script type="text/javascript">
                $("#ppmRole").change(function(e){
                    var roll = $("#ppmRole option:selected").val();
                    switch(roll){
                        case 'streetteam':
                            $(".steam").show();
                            $(".artie").hide();
                            break;
                        case 'artist':
                            $(".steam").hide();
                            $(".artie").show();
                            break;
                        default:
                            $(".steam").hide();
                            $(".artie").hide();
                            break;
                    } //end switch
                });
                $("#submitbtn").click(function(e) {
                    var username = $("#username").val();
                    var password = $("#passwrd").val();
                    var password2 = $("#passwrd2").val();
                    var email = $("#email").val();

                    if( username.length < 5 ){
                        alert("Username is required and must be at least 5 characters.");
                        return false;
                    } // end if

                    if( password.length < 2 || password2.length < 2 || password != password2 ){
                        alert("Password is required and both must match.");
                        return false;
                    } // end if

                    if( email.length < 5 ){
                        alert("Your email address is required.");
                        return false;
                    } // end if
                });
            </script>

<?php
            } // end if $_POST
        } else {
            echo "Registration is currently disabled. Please try again later.";
        } // end if user_can_register
} else {
   echo "Logged in";
   //wp_redirect( home_url() ); exit;
} // end if


get_footer();

?>
4
  • Email has a way of breaking URLs. Have you tried an URL shortner like bitly?
    – s_ha_dum
    Jul 10, 2013 at 1:47
  • What is set_html_content_type() defined as? Jul 10, 2013 at 8:53
  • add_filter('wp_mail_content_type',create_function('', 'return "text/html"; '));
    – jgravois
    Jul 11, 2013 at 2:18
  • I am trying bitly ... I wasn't aware of that service ... thanks. I will let you know if that works.
    – jgravois
    Jul 11, 2013 at 2:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.