Drupal: simple form forwarding data to another server - drupal

I need to add a page with a form in my Drupal website. This form should be submitted to another server (there is a php script ready to receive it on such server).
So, I don't need any database update, just a page forwarding the data inserted by users to another domain.
Do you know what's the easiest way to do it ?
thanks
ps. Also, I need to create a drop down menu with a list of countries (and regions for each country) as submenu

I am surprised noone mentioned hook_form_alter and setting #action to an external URL. This will make the form post directly to the other server if you have control of it you can easily redirect back. Lot easier than POSTing from your server. Another way would be to iframe the other script and use the target attribute (set $form['#attributes']['target'] = 'the_iframe' in hook_form_alter). Then you can use JS to 'move' the page after the submit. Upload POSTs to an iframe, you can look into that JS as well. How do you post to an iframe? discusses iframes and forms.

In your form, you can set #action to whatever URL you want. It will post to that url. If you need a GET, instead of a POST, you should also set the #method.
function my_form_builder() {
$form['search'] = array(
//..builds some form elements
);
$form[#action] = 'http://example.com';
return $form;
}

You could create a regular drupal form with the ususal validation stuff and instead of putting the date into the DB send it over to the other site (via post or get or whatever).

To POST to an external URL in your own custom form implementation or using hook_form_alter() to add another submit handler to an existing form, while not showing the request you will want to use drupal_http_request() to send a serverside http request. See this:
http://www.drupaler.co.uk/blog/validating-submitting-forms-other-websites-drupal/428
To accomplish this with the webform module you'll need what you learned above and something like the following:
In D6 /Webform < 3
http://drupal.org/node/543674#comment-2499674
In Drupal 7/Webform 3
http://www.midwesternmac.com/blogs/jeff-geerling/integrate-webform-3x-paypal

Related

Prepopulate Content Type Args when going to /admin/content in Drupal 7

I created a Drupal site. The admins who will be using the site for content management have no Drupal knowledge and I have been tasked with making this as easy as possible for them. I'm creating an admin control panel and I want a quick link that takes them to the admin content page, but with the "content type" prefilled. For example, for content I have pages, events, resources, and testimonials. I want to provide them with a quick link for editing content type EVENTS only. So it would go directly to admin/content with the type filter set to "events". The URL does not currently add args or anything like that.
Anyone know of a way to do this?
yes you can do this- just use this module: Drupal admin views which supports a REGULAR VIEW for admin/content. The View is set to use ajax though- just remove this option and save it and call /admin/content then. There you will see the resulting filters in the URL (you can even set their keys to a value you like inside the view). Set back to use ajax (if you like) and use the keys in the URL for type it's simple just call /admin/content?type=YOURTYPE

Redirect to wordpress page without page ID

I'm looking for a way to redirect to a specific wordpress page without knowing the ID.
I have a shortcode that is meant to redirect to a registration page once a button is clicked.
Before, I was able to just use a page ID. Now I am using WPML and the page ID's are all different for each language.
How can I redirect to a specific wordpress page without knowing the specific page ID for the current language?
Maybe you could use get_page_by_path() or get_page_by_title().
Both functions accept Post Type as argument, it's not only restricted to "pages". And they will return a full $post object, ie, $post->ID.
Maybe a WPML function is needed, an equivalent of those. Or maybe a combination.
See the docs for Language dependent IDs.
You could add a custom field which will be shared by all versions of the same article, and then query by that instead. Something like an article GUID.

Sitecore Web Forms for Marketers - use current URL within email body

I am trying to build a 'Tell a Friend' form for my Sitecore site using Sitecore's Web Forms for Marketers module and would like to include the URL of the current page within the body of the email. I have set the save action of my form to 'Send Email Message' and was wondering if it would be possible to use some variable to represent the URL of the current page, but can't figure out how to do it.
I noticed that if you link to a page when editing the HTML editor for the email template, the source looks something like this:
Name of page
...so perhaps it is possible to use some similar syntax to get the current context page?
I have also tried setting the save action of my form to 'Tell a Friend' but I can't see how to make this include any email content at all, let alone how to make the email include a link to the current page.
For reference I am using Sitecore 6.5.
I have an idea for this, but its more of a hack. Worth a shot:
Since the Email Editor supports inserting hooks for the dynamic fields (refer to section 4.2.2 of the WFFM User Guide [PDF]), why don't you create a Single-Line Text field on the form, call it "Current Page" and apply a unique CSS class to it (e.g. .current-page)
Using custom CSS, hide the .current-page element and using JavaScript, get the window.location.url and put its value into the .current-page input (the hidden SLT field).
Now you can use the hook [Current Page] in your email body.
Again, this is an untested idea, so I'm not sure if it will work.

Looking for ideas to implement an anonymous Suggestion Box in Drupal

I have a need to allow authenticated users to create content in Drupal anonymously. Ideally something like a Suggestion Box. The suggestion should have no fingerprint of who submitted it and ideally it should be submitted but not published until it is reviewed and approved.
Looking at the contact form and other modules, I haven't been able to get a clear direction on how to do this. Ideally I would think that at submission, I'd like to override the Authored By field and set this to anonymous. Is this the right direction or can I create a simple form that would be emailed to someone without ever creating a node?
I would suggest just creating a form using webform module.
If you don't want a node, just create a simple php form that sends a mail() on completion. You will need to enable the PHP filter and then just create a page with the PHP form in the content area.
If you wanted a node, you could create a custom content type called suggestions and then use a custom module to remove the author tag using hook_form_alter.
function uofm_usertasks_form_alter(&$form, &$form_state, $form_id) {
switch($form_id)
{
case 'suggestion_node_form':
$form['authored']['name']['#access'] = FALSE; // not sure if this is the right item in the form or not
break;
}
}

How to use hook alter form in module to register a user and also save some data in another table?

have a general idea on how to use hook alter to modify the feel of the registration form .
However the challenge I have is to not only have the user register, but to save some extra data into another table and then redirect user to a new page.
How would I get about doing that? Please help
Again, it'd be easier to plan what you're trying to do and take advantage of common solutions. I suspect what you're after is the Content Profile module.
add a custom function to your form, according to http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#submit-prop for more info
please notice the login page and the login block are different forms, with different form ids for your hook_form_alter.
Just implement hook_user(); when the first parameter is 'register', the registration form is being presented to a user, and the module can change it by adding new form fields (the module needs to return them to Drupal).

Resources