Trying to make sign up form using Wordpress.
The register -page is "page-register". So the link is supposed to point to itself.
This worked earlier without WP and with MAMP but can't get this work with wordpress and LocalWP.
<form action="<?php echo get_permalink('register'); ?>" method="post">
This go to 404 page. The permalink works as hyperlink but not as the form action attribute.
I also tried site_url() and get_page_link().
Solved. The problem was not in the form action, but in the form input name. So I changed this:
<input type="text" name="name">
to this:
<input type="text" name="uname">
Related
I wrote a plugin code. I want to show a custom form using my shortcode made by my plugin at every page I like. The Plugin and the form show correctly but after submitting and processing data to store on the database page not found error occurs. what is the best way to submit data from the frontend to the backend?
// this is my shortcode function code:
<?php
if(isset($_POST['submit_btn']))
{
// inserting data to database process that currently ends with
// Page not found error.
}
?>
<form method="post">
<input type="text" name="name">
<input type="submit" name="submit_btn" value="Store">
</form>
The error happens because of the input name:
I think it is reserved or something like that.
changing that solved my problem.
I newbie in drupal 7. I am writing new theme and I don't know how to add my class to form in drupal 7. I install ubercart to setup e-commerce website. I added new attribute for product (Size). I want to redesign in product page. In this page, It has size field but I don't know how to add my CSS. E.g:
<form action="/drupal-7.34/node/6" method="post" id="uc-product-add-to-cart-form-6" accept-charset="UTF-8"><div><div id="uc_product_add_to_cart_form-6-attributes" class="attributes"><div class="attribute attribute-1 odd"><div class="form-item form-type-select form-item-attributes-1">
<label for="edit-attributes-1">Size <span class="form-required" title="This field is required.">*</span></label>
<select id="edit-attributes-1" name="attributes[1]" class="form-select required"><option value="" selected="selected">- Select -</option><option value="1">39</option><option value="2">40</option><option value="3">41</option></select>
</div>
</div></div><input type="hidden" name="qty" value="1">
<input type="hidden" name="form_build_id" value="form-w06CKx7aNBiYShqfg8LiP98CaFLpEb8mgWzFYQWqnQ4">
<input type="hidden" name="form_token" value="JtZIrcKeIfXiVpwX43K6KqHPlZazR1klS1ht3W7PI9I">
<input type="hidden" name="form_id" value="uc_product_add_to_cart_form_6">
<div class="form-actions form-wrapper" id="edit-actions"><input class="node-add-to-cart form-submit" type="submit" id="edit-submit-6" name="op" value="Add to cart"></div></div></form>
I want to add my class to the select element. How can I do that?
In your theme directory there is file named theme_name.info . Inside of it there should be (or you can create it) array that defines css file which will be included on page. Check out explanation here:
https://www.drupal.org/node/171205
https://www.drupal.org/node/171209
So, you basically have to add path of your css file to that list and it will be included on every site page. Your html.php template must print out stylesheets variable (which will contain paths to css files). If you are not sure how to do it check how it's done on some standard drupal theme that comes with drupal installation.
After adding your css to theme info file don't forget to clear the cache!
Other way would be to include it manually, from page.tpl.php file. Just add there common CSS include line, like you would that in plain HTML file.
You can add CSS even from code with drupal_add_css() function, but that's a bit more advanced.
And you can use form id attribute to "aim" it and all inner elements with css.
I am working on a real estate directory using Drupal 7 and Views. I have a content type (called offering) with all the necessary fields on it and I want to be able to create a share form that will auto-populate with data from the content type. So for instance when you visit that property's page and click on the share button, a form pops up with the property name, title, property image and the subject line already filled in and all the user has to do is enter a recipient email and hit send. I was able to do this with custom php/jquery but I am wondering if there are any Drupal modules that can achieve the same thing since my code is a bit buggy and I have 3 forms on 1 page (share form, contact support and contact transaction team).
Here is a test link
http://greysteel.webmschf.com/?q=7-eleven-1
Here is some sample code of the node template that the share form shows up on
<form id="shareform" action="" method="post">
<input type="text" name="shareto" />
<input type="hidden" name="ttsubject" value="Greysteel Offering: <?php print $title; ?>" />
<input type="hidden" name="teamemail" value="<?php print render($content['field_team_emails']['#items'][0]['value']); ?>" />
<input type="submit" />
</form>
The above works perfectly, but the form is hard coded and cannot be administered through Drupal's back end. Is there any way around this? I've tried using the Webform module but I cannot find a way to automatically insert the property data into the webform.
You could use Javascript to accomplish this. You could print the value somewhere in the page, hide it with css, and on page load grab it's value and put it into the form field. that would be a quick solution.
Another way (probably your best option) is to write a hook_form_alter function that loads the node, grabs the data from it, and pre-populates the field.
function modulename_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'webform_client_form_###') {
$node = node_load(#);
$form['ttsubject']['#default_value'] = field_view_field('node', $node, 'field_name');
}
}
I have an issue where I am creating a simple custom search form in Wordpress 3.4 sitting in a template file.
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>">
<input type="text" value="" name="s" id="s" />
<input type="hidden" name="search-type" value="vacancies" />
<input name="submit" type="submit" value="Go" />
</form>
Upon submitting it hits a search.php file where further processing takes place.
<?php print_r($_GET); ?>
The problem is that I cannot access the get variables in search.php. I can echo here so I know I'm definitely hitting search.php but my get array is empty every time.
Any ideas would be a big help. I feel I may be making a rookie mistake...
I was having this problem too. The theme I am using (Roots) does some fancy rewriting of the search page URLs. So, searching for "french holiday" will be site.com/search/french+holiday instead of site.com/?s=french+holiday.
If you can't see the variable in the URL, you won't be able to access it using $_GET.
I changed back to the standard URLs and can now access my $_GET values.
Hope that helps.
I need to create a page in Wordpress. In it I need to have three tabs: Log In, Register, Forgot Password. Obviously, they will contain a login form, a registration form and a password recovery form. I have found instructions on how to create custom login form here:
http://www.tutorialstag.com/custom-wordpress-login-without-using-a-plugin.html
and how to create a custom registration form here:
http://www.tutorialstag.com/create-custom-wordpress-registration-page.html
Those two solutions seem good to me, so I'd like to use them. The problem occurs because both codes use $_POST for sending data and they both execute certain code in if($_POST) loops. Now, if I put both codes on the same page, and if a user tries to log in, it will also trigger the registration form's if($_POST) loop, and vice versa.
Is there a way for me to separate these two loops, something like if($_POST['login']) and if($_POST['register']) or in some other way?
Ideally, I want to create a plugin which adds shortcodes for login form, registration form and forgot password form. What is the best way to separate codes and yet make them work together in the same page?
Also, is there perhaps an easier way to achieve what I need? I've tried looking for plugins that might look alike, but with no luck.
Yes, and pretty much as you've described here.
Set the 'name' attribute on each of your submit buttons - e.g.
<input type="submit" name="login" value="Login" class="mybtnclass" />
Then when parsing, check if that value is set
if(isset($_POST['login'])) :
// Do login
elseif(isset($_POST['register'])) :
// Do registration
elseif(isset($_POST['reset'])) :
// Do password reset
endif;
EDIT:
An alternative is to give all the buttons the same 'name' and then test the 'value' attribute to determine which was pressed e.g.
<input type="submit" name="submit" value="Login" class="mybtnclass" />
<input type="submit" name="submit" value="Register" class="mybtnclass" />
<input type="submit" name="submit" value="Reset Password" class="mybtnclass" />
<?php
if('Login'===$_POST['submit']) :
// Do login
elseif('Register'===$_POST['submit']) :
// Do register
elseif('Reset Password'===$_POST['submit']) :
// Do password reset
endif;
?>