| Post |
|
aproapeom - Guest
2:09 pm - July 17, 2007
|
| |
|
hi there and the first thing i want to say is that your plugin is great.
i
needed a little modification, in such way that when a user comments a
post, the email should be sent to the email address of the writer .
does that make sense ?
i tried inserting into the " admin email "
the value <?php get_the_author_email ?> , but i noticed that the
value is taken as it is, and the function does not start at all . is
there any way to declare that field's value via a function ?
10q in advance, and keep up the good work
|
|
|
Oliver
- Admin
6:25 pm - July 17, 2007
posts 3921 |
| |
|
Isn't that what the general WP post comment feature is for?
If you don't want other people to see those post relevant user comments, you could simply remove the code that shows the comments from your theme...just a thought.
On the other hand you can of course use cforms as well, if you need dynamic admin addresses, you can use your code and replace the $to variable in the mail() functions with it (in cforms.php) , e.g.:
search for @mail( and replace:
@mail($to, ... with @mail(get_the_author_email(), ...
This should work.
|
|
|
aproapeom - Guest
10:35 pm - July 20, 2007
|
| |
|
thank for your answer, i will try as you said, and post the result here
|
|
|
Oliver
- Admin
9:09 am - July 21, 2007
posts 3921 |
| |
|
Great! Also, note that you need to only make the above adjustment for the admin email, neither for the auto confirmation nor CC email.
|
|
|
aproapeom - Guest
12:17 pm - July 24, 2007
|
| |
|
ok so thank you for your support.
i replaced the fields as you indicated me.
but i still have a problem. :d
i have two forms, one forms works, the other does not. Strange, right ?
|
|
|
Oliver
- Admin
6:48 pm - July 24, 2007
posts 3921 |
| |
|
Very odd indeed. Have you cloned the first form or did you start the second form from scratch?
Try cloning the first form and give this new form a shot, if it also doesn't work we need to dig deeper. If it does, chances are you misconfigured the second form that currently doesn't work.
|
|
|
aproapeom - Guest
1:09 pm - July 25, 2007
|
| |
|
i noticed that the second form was not closed, closed it , but this did not fixed the problem.
so i have cloned the first one and now is working as it should
thank you !
|
|
|
Ann - Guest
10:18 pm - September 4, 2007
|
| |
|
Dear Oliver,
I am trying to replicate this dynamic admin email feature by following your instructions above.
I modified cforms.php, line 626 from:
$sentadmin = @mail($to, encode_header($vsubject), $fmessage, $headers);
To:
$sentadmin = @mail(get_the_author_email(), encode_header($vsubject), $fmessage, $headers);
This resulted in no email being received at all (at the author email address).
Since I thought it was likely that the author email address was not fetched correctly I tried replacing $fmessage with the fetching function instead:
$sentadmin = @mail($to, encode_header($vsubject), get_the_author_email(), $headers);
This resulted in a totally blank email being sent to the mail address defined in the form GUI (as expected).
It seams like the get_the_author_email() function call is somehow outside the loop when called from cform.php which results in the NULL value return.
Please let me know you think and what I am doing wrong
Ps.
The form (nr 2) used in the test above has then been entered into the default single.php just above the comment template, like this:
…
<?php insert_cform('2'); ?>
<?php comments_template(); ?>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
…
|
|
|
Oliver
- Admin
10:32 pm - September 4, 2007
posts 3921 |
| |
|
Have you tried in non-ajax mode? Is it working then?
You're right, in Ajax mode the loop-context is lost and you would need to pass the post-ID to the ajax php routine.
The good news: with a few tweaks, you can 'abuse' the Tell-A-Friend feature to pass the post-id on to the ajax function (the code is already in cforms.php).
The only question left is, can get_the_author_email() support an post-ID as a parameter, e.g: get_the_author_email( ID ) ?
|
|
|
Ann - Guest
11:11 pm - September 4, 2007
|
| |
|
You are so quick in your replies 
Yes please give me some pointers on how to get hold of the post ID using the Tell-a-friend feature.
In reality I am storing the admin email addresses in custom fields which I access by using:
<?php get_post_meta($post->ID, $key, true); ?> where $key denotes the custom email field.
So if there is way to get hold of the Post ID from within cform.php and then
use
...
$to = get_post_meta($postID, $key, true);
$sentadmin = @mail($to, encode_header($vsubject), $fmessage, $headers);
...
It would work perfectly.
|
|
|
Oliver
- Admin
11:27 pm - September 4, 2007
posts 3921 |
| |
|
So this is for ajax only of course, since the loop context is not lost when cforms falls back to non-ajax submission mode.
Open cforms.php (v5.4) and look for lin ~2078:
... <input type="hidden" name="cforms_pid'.$no.'" ...
and move it outside of the if block (above it is fine).
This will include the post->ID in the form and pass it to the ajax php function (via Javascript).
In cforms.php, line 361:
$AjaxURL = $content[2];
The post->ID gets extracted. Here you could add your specific code to get the custom field values, to essentially pass it on to the mail() command.
|
|
|
Ann - Guest
9:10 am - September 5, 2007
|
| |
|
Many thanks!
Shall a ‘Tell-a-friend’ field be added to the form to get
this to work?
Ps
1. The released v5.4 solved the Captcha reload feature perfectly.
2. I tried the non-ajax submission mode with no success.
|
|
|
Ann - Guest
10:06 pm - September 5, 2007
|
| |
|
Managed to get the additional field (<input
type="hidden" name="cforms_pid'.$n...) in the form using your ajax submission guidelines above.
Please have a look at the source code for http://bytapocket.nu/triller/man-som-hatar-kvinnor/
But I cant figure out how to call for the $content
variable in the mail-function. I tried the following with the hope of getting an
email containing only the PostID.
line 626:
$sentadmin = @mail($to, encode_header($vsubject), $AjaxURL,
$headers);
|
|
|
Oliver
- Admin
10:54 pm - September 5, 2007
posts 3921 |
| |
|
Ok the post-ID is now part of the form, can you now access your custom values (for a fiven post, e.g. author email)?
What are you trying to send to the post author?
What do you get in the email (if you get one at all)?
Is the $to now being properly set?
Just passing $AjaxURL may not be good thing, since you may be missing some of the header info (that in fact have to go into the body) - for testing rather try: $fmessage .'(postID='. $AjaxURL .')'
What do you need the $content for?
|
|
|
Ann - Guest
7:26 pm - September 6, 2007
|
| |
|
Sorry for making your confused and I really appreciate your patience.
I can not access my custom values since I have not been able to pass on the post-ID to the cform mailfunction. The value inside $AjaxURL is simply blank.
For example;
$fmessage .’(postID=’. $AjaxURL .’)’
Will result in an email ending with just (postID=).
What are you trying to send to the post author?
To test if the post-ID is properly returned from the form I am trying to send the post-ID in the message body of an email. When this is successful I know that I can use the post-ID to get the proper custom values for the $to variable.
What do you get in the email (if you get one at all)?
I get a blank email (no post-ID)
Is the $to now being properly set?
I do not which to mess with $to until I know that the form is returning a proper post-ID.
What do you need the $content for?
I thought that the post-ID was stored in the $content-array.
|
|
|
Oliver
- Admin
7:46 pm - September 6, 2007
posts 3921 |
| |
|
Thanks for clarifying!
Sorry I forgot something on my end: in addition to this line
... <input type="hidden" name="cforms_pl'.$no.'" ...
you also need to move the other one:
... <input type="hidden" name="cforms_pid'.$no.'" ...
outside the IF block, which of course makes the IF superfluous :-)
See if that makes it work (and properly sets the $AjaxURL).
|
|
|
Doug - Guest
3:19 am - October 10, 2007
|
| |
|
Hi Oliver,
I've been trying to follow what Ann has been up to, because it's similar to my own case, but unfortunately I've gotten a bit lost.
In my case, I am deploying a contact form on each author's bio "page" (I use quotes because it's not an actual Page in Wordpress terms... otherwise this would be too easy!) and would like that email just to go to the individual author. The problem is that the author.php page is of course dynamic and simply pulls the user data as an array and displays it. I am using the insert_cform() function to generate the form. Honestly, if there was just a variable in the function to pass the recipient's address, I'd be all set, since it is available to me in the array. But lacking that, I've been unable to get it to work so far by editing cforms.php.
I'm guessing it's some problem with the variable being out of scope or something like that; it's been about 3 years since last time I did any real coding so bear with me!
This really is a fantastic, intuitive, smart, and powerful plugin... I'm impressed it can do as much as it can, let alone what I'm trying to hack into it!
Thanks,
Doug
|
|
|
Oliver
- Admin
7:42 am - October 10, 2007
posts 3921 |
| |
|
I'm happy to send you a (stable beta) copy of v5.5 which comes with a WP Comment feature, ie. the user gets to choose whether his note is in fact treated as a regular comment on the post or as a note (email) to the post author.
With very little modification you could also make this feature to not be optional and only send the message as a note.The only requirement is that the post including the form is written by that person with a valid email address in his WP profile.
You could choose to replace your standard WP comment form with the cforms one (with the benefits outlined) or simply use the cforms one for those specific bio pages. All up to you.
Of course you can run these cforms forms in parallel, have a standard contact form (email goes to the one configured in cforms), a WP comment mimicking form and ...well, how many other ones you need.
|
|
|
Doug - Guest
8:48 pm - October 10, 2007
|
| |
|
Hmm, interesting. That sounds useful, although if I'm not mistaken it doesn't actually solve the problem I'm grappling with... in this case the author pages HAVE NO AUTHOR. They are not posts. They are not pages. They probably don't exist formally as far as WP is concerned - they are strictly dynamically generated when the user follows the post author link under a post!
Does this make sense?
|
|
|
Oliver
- Admin
9:35 pm - October 10, 2007
posts 3921 |
| |
|
Sorry, misread your initial post. You're right, neither the solution above nor the new WP Comment feature will in this case help you.
The only solution would be - like you said - to pass on the recipients address at run-time. Which currently is not supported.
A possible workaround (haven't tested it though) may be to utilize the 'Multiple form mail recipients' feature.
- Add the authors emails addresses to the cforms admin email setting: email1 (Joe), email2 (Pete), email3 (Mike)
- In your dynamic form include a multi-recipients field that gets 'build' at run-time (see examples below)
- Via CSS hide the entire input field, so users neither can see it nor change it
re. item 2 (dynamic field):
in order to pick the right author, you need to dynamically change the order and IDs, e.g. to pick email1 (Joe), the field name needs to be:
Send to#Joe|0#Pete|1#Mike|2
if you you'd like to send it to Pete,
Send to#Joe|1#Pete|0#Mike|2
In the code (cforms.php) you only need to change this line (~1999):
$field.= '<option value="'.(($field_type=='emailtobox')?$jj:$opt[1]).'" '.$checked.'>'.$opt[0].'</option>';
to
$field.= '<option value="'.$opt[1].'" '.$checked.'>'.$opt[0].'</option>';
That should be it.
|
|