Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jfox77

    (@jfox77)

    Figured it out! I needed to pass $post_ID into my custom function and not use the loop in the function.

    function dci_email_answer($post_ID) {
    //just do your stuff
    }
    
    add_action('publish_post', 'dci_email_answer');
    Thread Starter jfox77

    (@jfox77)

    I tried this out but nothing seems to happen. In the documentation it mentions “Action function arguments: post ID”. Do I need to pass an ID? If so what is the syntax to grab the ID and call add_action?

    Here’s what I have in my theme’s functions.php file so far:

    function dci_email_answer() {
    
    	if (have_posts()) : while (have_posts()) : the_post();
    
    		$strMailTo = 'julie@fmywebsite.com';
    		$subject = 'Answer from mywebsite.com';
    		$email = 'info@mywebsite.com';
    		$mailBody = "Thank you for submitting a question!  Click here to view the answer. <br /><br /> " . the_permalink();
    
    		mail($strMailTo, $subject, $mailbody, "From: $email");
    		header("Location: http://www.mywebsite.com");
    
    	endwhile; endif;
    
    }
    
    add_action('publish_post', 'dci_email_answer');
    Thread Starter jfox77

    (@jfox77)

    Thanks, dralezero! I was thinking it was something along those lines. I’ll give it a shot!

    jfox77

    (@jfox77)

    Thank you, songdogtech for saving the day! I was locked out of my admin and my htaccess file was corrupt so none of my permalinks were working. I created a fresh htaccess file, with permissions set to 644 and the following code:

    RewriteEngine on
    
    <IfModule mod_rewrite.c>
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    That fixed things so I could get back into my admin and my permalinks were restored.

Viewing 4 replies - 1 through 4 (of 4 total)