Issue with Wordpress Contact Form 7 Plugin - Dynamic Text Extension - wordpress

I use the Contact Form 7 plugin for contact forms on our site. I am using this on a WP installation with multiple sites. We have employment application forms on each site, and to identify the site when we do a REST call to our webapp, I would like to include the site_id (or blog_id, I'm unclear on which is the right name) so it can be used to reference the WP site in the other app. I installed the Dynamic Text Extension for this particular task, and this is my first attempt, based on the help docs, to add a hidden field with the blog_id:
[dynamichidden blog_id id:blog_id "CF7_bloginfo value='blog_id'"]
and end up with this:
<input name="dynamichidden-927" value="Elite Trade Painting Calgary" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" id="blog_id" aria-invalid="false" data-hasqtip="true" type="hidden">
I should note that no matter what I put in the tag, the same value comes up. I know I am editing the right form because if I delete the tag, it disappears completely – but no matter what I change, it always has the wrong value.
https://elitetradepainting.com/calgary/employment-opportunities/

My mistake was looking at the wrong page and thinking that bloginfo() returns the blog id - it doesn't. The DTX developer answered my question in WP forums and advised me to use a shortcode, so I wrote a callback that uses get_current_blog_id:
in functions.php:
function get_blog_id_callback() {
return get_current_blog_id();
}
add_shortcode('get_blog_id', 'get_blog_id_callback');
Then the snippet for the control in the Edit Contact Form page is as simple as:
[dynamichidden blog_id "get_blog_id"]

Related

WordPress comment form autocomplete off

I need to disable autocomplete function for comment forms defined in comment-template.php file
2478 '<form autocomplete="off" action="%s" method="post" id="%s" class="%s"%s>'
This is my working version - but I need to be able to keep this working after update.
What is the clean way to patch WordPress core files when there is no do_action or other method for doing so.
you can create a child template, then override specific file into specific path.
after all you can be sure updating your template does not effect your modification
so you create a comment-template.php in your child template
for creating child template please visit following link
https://developer.wordpress.org/themes/advanced-topics/child-themes/

Wordpress Shortcode syntax

I am using the Avada theme on my WordPress which makes use of Countdown Boxes, constructing pages using the provided Fusion Page Builder. The countdown box will show the number of days to a certain date which is output through a plugin called Days-Until. Syntax for implementing this: [days_until date="15 April 2015"].
I am trying to use this Days-until shortcode and pass the value to the countdown box shortcode using the Fusion (WYSIWYG Editor):
[counters_box columns="4" color="" title_size="" icon_size="" body_color=""
body_size="" border_color="" class="" id=""][counter_box value="[days_until
date="4 April 2015"]" unit="" unit_pos="suffix" icon="" direction="up"]"
unit="" unit_pos="suffix" icon="" direction="up"]Text[/counter_box]
Unfortunately the code doesn't work, and the following is displayed.
0 (in the counter box)
unit=”” unit_pos=”suffix” icon=”” direction=”up”]” unit=”” unit_pos=”suffix” icon=”” direction=”up”]Text
Is it even possible to do what I'm trying to do?
Thanks
It's not possible to nest one shortcode inside another (i.e. your days_until shortcode inside the counter_box) without some programming.
It's a commercial theme so we're unable to see the original PHP code.
What'd you need to do is edit the code for counter_box so it calls do_shortcode on the value parameter.
do_shortcode is a function that expands any shortcodes in the supplied text (in the same way they are if they've been pasted into the content field of a Page or Post), so the days_until code will be converted to a number that the counter can use.
I would suggest getting in touch with the theme developer.
Further reading: WordPress Shortcode API

Wordpress Form Submit button GETS (or POSTS) form data to external page

We have a wordpress website that does marketing display, but now we want to allow a customer to submit an email and selection to a separate website with a landing page that will handle the backend DB work and finish them in the other website.
Something like,
www.ourmarket.com/getdata (on Submit button click GETS to...)
www.ouradminsite/landingpage.aspx (which processes the data that the use will not see then...)
www.ouradminsite/login.aspx (where the user can now login)
I am not familiar with WP at all, but I was able to create a page with a form that has the textbox/combobox I need.
I thought it would be something simple, but somehow it seems not. I read about AJAX and doing something in functions.php and creating a custom .js file, but when working on the marketing site I find no way to add this type of function in.
My fall back is to have the WP page just have a link to a generic landing page where they enter data, but it would be visually jarring to the customer unless I duplicate the WP site for one page.
Is there an easy way to just tell WP to redirect to an external page with a GET?
UPDATE--------------
I like to think I'm making progress. I found a link that may have given me a good start. I added a function to the functions.php file located in my WP theme. It starts like this:
add_action("gform_post_submission_4", "set_post_content", 10, 2);
function set_post_content($entry, $form){
//Gravity Forms has validated the data
//Our Custom Form Submitted via PHP will go here
// Lets get the IDs of the relevant fields and prepare an email message
$message = print_r($entry, true);
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('myuser#mycompany.com', 'Getting the Gravity Form Field IDs', $message);
**wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);**
}
From there I tried to edit the function to do that wp_redirect, just a simple one to start. This is added under the mail statement:
wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);
From this link, when I fill out the form I can get the email, but the new page did not display. I added the exit; line and still got the same result, the page seems like it hangs.
The end result is that I need to have the new website landing page display (after it processes the data from the Wordpress form.
What am I still missing?
yes use wp_redirect()
if($_POST):
$textbox=$_POST['textboxname'];
$url= 'url'.'?custom=hello&textbox='.$textbox.'&anothervalue='.$anothervalue;
wp_redirect($url);
exit;
endif;
you can easily add the variables to the string as needed. The easiest way to control the url properly is to post the information to the same page , catch the post and redirect (place before get_header call or any output has started)
The other way is php Curl which is more difficult esp when dealing with .asp pages, but if you have access to the other server it makes figuring it out easier!

I'm trying to integrate PayPal Payment with Contact Form 7 in WordPress, and my Redirect isn't working

I'm working on a Charity site where we want to accept membership payments and donations via paypal.
I am having a problem with Contact Form 7 and redirection to PayPal with a variable payment amount. I'm really hoping that someone can assist or shed some insight on this problem for me.
I read This Post, which made it sound quite easy but, while my email is being sent, the form isn't redirecting to PayPal, in fact it's not doing anything at all, not even giving me the "thank you your form has been submitted" notice.
my form has this line: £[text* AmountPaying 6/ id:PayingThis]
And under "Additional Settings" I have inserted this:
<script>
function my_redirect() {
var price = document.getElementById("PayingThis").value;
var url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=#####&currency_code=GBP&amount="+price+"&return=http://www.example.org/join-or-renew-your-membership-online/";
window.location = url;
}
</script>
on_sent_ok: "my_redirect();"
does anybody have any experience with this ?
Thanks for the comments !
With some help troubleshooting from a friend I have figured out how to make this happen with contactForm7 - in fact, I believe you could extend this solution, and submit a lot of dynamic information directly to PayPalmy problem.
This is what I did - and it's essentially the same as this guy does here
BUT, instead of putting that code in the "ADDITIONAL SETTINGS" Area of the CF7 Form page - I added this:
<script>
function my_redirect() {
var price = document.getElementById("PayingThis").value;
var url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=#######&currency_code=GBP&amount="+price+"&return=http://www.example.org/join-or-renew-your-membership-online/";
window.location = url;
}
</script>
up at the top, with the rest of the Form building html and tags, just before the code for the form itself:
Your Name (required): [text* your-name]
etc.
and then in the Additional settings box.. I only called the function
on_sent_ok: "my_redirect();"
and it worked! it takes the value the user enters in the "How much do you want to give us" box, and submits it to paypal
I hope others can benefit from this
thanks again for taking the time to view and help
-5tratus
Contact Form 7 is a great plugin but creating a form for PayPal gets a little tricky. Gravity Forms would be a great options but you would need the developers license that cost $200.
My recommendation is to look up the PayPal form API and create the form yourself, from scratch and integrate it OR you should have a look at the Advanced Custom Fields plugin, and the PayPal Field Add-on for Advanced Custom Fields! It's all free.
It enables you to set a form on any post/page/etc with a paypal button. All you have to do is add the <?php the_field('NAME_OF_YOUR_FIELD'); ?> to your template, wherever you want to display it.
http://wordpress.org/plugins/advanced-custom-fields/
http://wordpress.org/plugins/advanced-custom-fields-paypal-field/
Thanks 5tratus. Works.
An old support thread (https://wordpress.org/support/topic/contact-form-7-paypal-integration-1) was getting as far as redirecting to PayPal, but then PayPal was giving an "Page Not Found" "You have requested an outdated version of PayPal" message.
I didn't need price or any extra variables, so I cleaned it up to just redirect to the product page. Here's what I used and it works:
<script>
function my_redirect() {
var url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=[PUT YOUR BUTTON ID HERE]";
window.location = url;
}</script>
As 5tratus says, put the above code in at the bottom of the form code itself, then put
on_sent_ok: "my_redirect();"
in the "additional settings" part.
Refer this useful plugin - https://wordpress.org/plugins/contact-form-7-paypal-extension/

Change size of user/password login box

I don't know how to change the size of the login username/password boxes on the drupal site that I'm trying to build. I'm stumbling through the theming, and don't know where to find the file that needs to be changed in order to have boxes that fits the aesthetic (so a file path would be very helpful).
I'm hoping it's a css solution. You can see the site first hand at innovatefortomorrow[dot]org and my firebug screenshot http://www.jonrwilson.com/user-login-form.png (I don't have enough reputation points to attach an image or two hyperlinks).
Thanks!
read this as well! This is an alternative answer!
Ok... you are about to enter one of the most exciting and complex features of Drupal: the form API or - for brevity - FAPI. Some theory first, and then the solution! :)
All forms in Drupal are built by the drupal_get_form() function, that accepts an array as parameter. Each field in the array is basically a field of your form, and each field has a number of proprieties, each of them define additional characteristics of the the field, like for example its default value, if it is required or optional and - yes - in the case of textfields... how large they have to be! You can find a detailed explanation of the structure of form arrays here on the drupal site.
The beauty of the form API is that the function that renders the form invokes a number of hooks at various moments during its building process, so you can implement these hooks in order to "alter" a form before it is finalised and sent to the browser.
The most commonly hooks for form alteration are hook_form_alter() and hook_form_FORM_ID_alter(). The first is executed for any form processed by the drupal engine, the latter only for the specific form named "FORM_ID". I will not get into any more details on the internal working of the form API, but here you can read more.
As for your specific case, I assume you are using the standard "user block" shipping with Drupal. In this case I suggest you implement hook_form_FORM_ID_alter() in a form similar to this one:
mymodule_form_user_login_block_alter(&$form, $form_state) {
$form['pass']['#size'] = 43;
}
Hope this helps! :)
I think in this case you have to go to the your html ( or tpl), not your css file to edit it.
One quick way is to search the relevant string (i.e., size="43" name="name" etc) in order to find the correct part.
Here is the way to theme a user login form in drupal 6 with the preprocess function in a template file and not in a module.
in template.php put this code:
function yourThemename_preprocess_user_login(&$variables) {
$variables['form']['name']['#size'] = 15;
$variables['form']['pass']['#size'] = 15;
$variables['rendered'] = drupal_render($variables['form']);
}
create a new file user-login.tpl.php (if it's not already there) and just paste this:
<?php print $rendered; // this variable is defined in the preprocess function user_login and print the login form ?>
Don't forget to clear theme cache or system cache in the performance settings.

Resources