How to add custom fields to WooCommerce product data panel - wordpress

I have created a custom product type for events in WooCommerce. Now I want to add some custom fields to it.
This can be achieved with functions like woocommerce_wp_select(), woocommerce_wp_text_input() etc. However, as far as I know, whith these function you can only add text input fields, textarea's, select boxes and select dropdowns.
I want to add a date picker field, a file upload field and an url input field.
I have created these fields and they do render on the admin panel as they should, but the values are not saved (although I'm using the action hook 'woocommerce_process_product_meta'). Only the first 2 fields (event_type and event_location), which are created with the WooCommerce function, are stored properly.
What am I doing wrong here?
My code:
add_action('woocommerce_product_data_panels', 'okappi_add_custom_fields');
function okappi_add_custom_fields()
{ ?>
<div id="event_details" class="panel woocommerce_options_panel hidden">
<div class="options_group" class="show_if_event">
<? woocommerce_wp_select([
'id' => 'event_type',
'label' => __('Event type', 'custom'),
'wrapper_class' => 'show_if_event',
'value' => get_post_meta(get_the_ID(), 'event_type', true),
'options' => array('online' => 'Online', 'international' => 'International', 'internal' => 'Internal'),
]); ?>
<? woocommerce_wp_text_input([
'id' => 'event_location',
'label' => __('Event location', 'custom'),
'wrapper_class' => 'show_if_event',
'value' => get_post_meta(get_the_ID(), 'event_location', true),
]); ?>
<p class="show_if_event form-field event_start_date_field">
<label for="event_start_date">Start date</label>
<input type="date" id="event_start_date" name="event_start_date" class="date short">
</p>
<p class="show_if_event form-field event_end_date_field">
<label for="event_end_date">End date</label>
<input type="date" id="event_end_date" name="event_end_date" class="date short">
</p>
<p class="show_if_event form-field event_pdf_field">
<label for="event_pdf">PDF upload</label>
<input type="file" id="event_pdf" name="event_pdf" class="date short">
</p>
<p class="show_if_event form-field event_link_field">
<label for="event_link">Event link</label>
<input type="url" id="event_link" name="event_link" class="date short" placeholder="https://www.my-event.com/">
</p>
</div>
</div>'
<? }
add_action('woocommerce_process_product_meta', 'save_custom_fields');
function save_custom_fields($post_id)
{
$product = wc_get_product($post_id);
$event_type = isset($_POST['event_type']) ? $_POST['event_type'] : '';
$product->update_meta_data('event_type', sanitize_text_field($event_type));
$event_location = isset($_POST['event_location']) ? $_POST['event_location'] : '';
$product->update_meta_data('event_location', sanitize_text_field($event_location));
$event_start_date = isset($_POST['event_start_date']) ? $_POST['event_start_date'] : '';
$product->update_meta_data('event_start_date', sanitize_text_field($event_start_date));
$event_end_date = isset($_POST['event_end_date']) ? $_POST['event_end_date'] : '';
$product->update_meta_data('event_end_date', sanitize_text_field($event_end_date));
$event_pdf = isset($_POST['event_pdf']) ? $_POST['event_pdf'] : '';
$product->update_meta_data('event_pdf', sanitize_text_field($event_pdf));
$event_link = isset($_POST['event_link']) ? $_POST['event_link'] : '';
$product->update_meta_data('event_link', sanitize_text_field($event_link));
$product->save();
}

Related

Add Field To Custom WP Login Form

I have a custom login form that I display on a page using the following:
$my_login_args = apply_filters( 'my_login_page_args', array(
'echo' => true,
'redirect' => site_url( $_SERVER['REQUEST_URI'] ),
'form_id' => 'my_login_form',
'label_username' => esc_html__( 'Email Address' ),
'label_password' => esc_html__( 'Password' ),
'label_remember' => esc_html__( 'Remember Me' ),
'label_log_in' => esc_html__( 'Sign In' ),
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'remember' => true,
'value_username' => NULL,
'value_remember' => false
) );
wp_login_form( $my_login_args ); ?>
I need to pass a custom variable ($my_custom_id) stored in the login page through to the redirected page a user sees after login. Is there any way to append the URL with this variable using POST or GET or is the best solution to add this as a hidden field in the form?
Also, in terms of adding an extra field to the form I've tried adding a custom input box to the form using
add_action('login_form','my_added_login_field');
function my_added_login_field(){
//Output your HTML
?>
<p>
<label for="my_extra_field">My extra field<br>
<input type="text" tabindex="20" size="20" value="" class="input" id="my_extra_field" name="my_extra_field_name"></label>
</p>
<?php
}
However this only adds the field to the main Wordpress login and not my custom form. Any thoughts on how best to proceed?
You can you add custom field in login form at top, bottom, and in middle.
I have added login field in login_form_middle.
For Reference https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/general-template.php#L390
https://codex.wordpress.org/Customizing_the_Login_Form
/*
You can use these hooks as well to place your fields
login_form_bottom - login_form_top - login_form_middle
*/
add_filter('login_form_middle','my_added_login_field');
function my_added_login_field(){
//Output your HTML
$additional_field = '<div class="login-custom-field-wrapper"">
<label for="my_extra_field">My extra field<br>
<input type="text" tabindex="20" size="20" value="" class="input" id="my_extra_field" name="my_extra_field_name"></label>
</div>';
return $additional_field;
}

Hidden ACF front end form not saving

I'm using the front end form functionality of Advanced Custom Fields which works fine when on a standard page but when it's within a div that's hidden (either using Jquery to hide it or setting css to display none) the update button stops working and no data is saved. It doesn't show any errors in the console either.
How can I get around this? It's integral that the ACF form is hidden.
This is the code I'm using to display a particular set of fields:
<?php $activity_information = array(
'post_id' => $ID, // post id to get field groups from and save data to
'field_groups' => array(1781), // this will find the field groups for this post (post ID's of the acf post objects)
'form_attributes' => array( // attributes will be added to the form element
'class' => ''
),
'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
'html_field_open' => '<div>', // field wrapper open
'html_field_close' => '</div>', // field wrapper close
'html_before_fields' => '', // html inside form before fields
'html_after_fields' => '', // html inside form after fields
'submit_value' => 'Update', // value for submit field
'updated_message' => '', // default updated message. Can be false to show no message
); ?>
<?php acf_form( $activity_information ); ?>
CSS:
.reveal-area {
display: none;
}
This is what it's generating (with the 3 dots representing all the fields):
<section class="row reveal-area">
<div class="columns">
<form id="acf-form" action="" method="post">
<div id="acf-form-data" class="acf-hidden">
<input type="hidden" id="_acf_post_id" name="_acf_post_id" value="1773"> <input type="hidden" id="_acf_nonce" name="_acf_nonce" value="6798af667b"> <input type="hidden" id="_acf_validation" name="_acf_validation" value="1"> <input type="hidden" id="_acf_ajax" name="_acf_ajax" value="0"> <input type="hidden" id="_acf_changed" name="_acf_changed" value="0"> <input type="hidden" id="_acf_form" name="_acf_form" value="cllBUjlDU09QMUtyVXBKalJ3VmVsS3lFQXpPcHEwUm5KNmdHRzVrYXRnY0RCT0xrUndDMWhQTXg4UVJzZm1xTHlVQllDWkFrV2R4ZzNmT3FQdjhnNWJSMFdaTUNHYlNjNzZ5OEcvbzBkOHROcW5BYXlRYmdQZ1R0bW93UmJyUXV0MEZQVmZkWlZSbEVGV2hqS1E2dHJxSjFxR2xuU1gxZUwydGRrR254VjZuTTRHdFV0WXBmRGJTeS9KQ2VIbkkxR0Rxcit0ZWlDck9IL2pOYk16ODVqQ28reFBNR05QSWRUc3R2Z1E2L0tnbWZrMXlhRDRCNU5ZWFk0M0MyTkpqNkZpa254NXBudk1qZk5uNytRZDN0NmFpN0FOdkFXTWRDYXNUd2gzRXJxeXNqaHJUaU1rRTJTMENiZVhsNHV6b1ZWbGUxTHJwTm1YQTEzUlozcmNrWU5mdFdYSjF3WDNINEtJWGdVREsvNTNFRzg5dHVKVGxqTmFILyt1ci9tOGNDYTYyVUk1eDB2ZUZCdEg3R3JHQmhtSWZyczkvS3diOHIwY2FwOWNISTdmWlhsK241Tmdib2UyZjlNM1o0RnhCOW5QdjRiL2t5cm1HVTlmR3BCek1mYnAyUkFRRWlmNlJqcjdTS3g2dmdUOCtvRjBWL28rcFhmOWVrV2ViV3ZkUHN4NVZuOXBIMzR4RStUQUxMTksyVnN0YjNBVnFBU1crb3pWUzA3TUpSVkJJN2RjYmxnWnUzMk95RE42b2tqc1ROdnFVRFpmRFZSU3BvaFIxOWkvS042WHh6NGlIQlRBSlBRNXJVV1pHL0ZRL2Nid3RxbmRkcjNHREd2bHlkTmFnMnUrYjhRc0FpWjhhNkx1d3JoUU5yYi9kYnNxSWllSnU1a3E5bmhCNU9mSS8xK08rZ3VLN0tsYWZYV0N0ZElqeFJ2TkNBNEhsVC9ocHAwaklIMHZGTkFjKzBuZEhrZzU4cW9TRzNNL0k3Z2puWDAyRWZoOHNaeXF1UHlOUHR6aTA1L1B1QVVWMXd3WC9ybGlQOCsyVGZRdFdDaXpsbElZbll1UVJzQ3lpQjBoaEx0cmNYbG5hdTV3bGpNSVZab1ZhSUltWXRBWnhGMVplVjVFZXNBNzMzM0dSZmx1YWErUmE2WlpnYU11WUR2VS9kU1ZPRFlVNWZMYkZkNVZtZXZLMnBSN2t2K28xVzBQbDh0ZU94MUN4VEE0VDRBU0MxSGdHc2htZjNWR1phbUlGcUtnQ0h2d1Q0cDEwUUFjM1cwQkZ4RzltWUN2YjdwSTBhcGxtYkp4a05rRG4yK3JwSERFY1A5TFRFNGpJUzBmZXZ2ZkdZWHRzcUdNaXk2QTJSbFMxdnZmOURobE5xdGdBRWtieFZjZnRFbThrWFdWa2xWaVpFSnFQOWg0NDZNWDlrOXdjQzFXS0lsUWt4T1pRWENpd246Ok07hUIWm2U5p0Q9mApuvuM=">
</div>
...
<div class="acf-field acf-field-text acf-field--validate-email" style="display:none !important;" data-name="_validate_email" data-type="text" data-key="_validate_email">
<div class="acf-label">
<label for="acf-_validate_email">Validate Email</label>
</div>
<div class="acf-input">
<div class="acf-input-wrap">
<input type="text" id="acf-_validate_email" name="acf[_validate_email]">
</div>
</div>
</div>
</form>
</div>
<div class="acf-form-submit">
<input type="submit" class="acf-button button button-primary button-large" value="Update">
</div>
</section>
When you didn't make changes in the fields of the form, ACF ignores the submitting. Normally the form has a hidden field with id _acf_changed and value 0. When you are editing a field this value changed to 1.
So try to add JS script AFTER YOUR FORM:
<script type="text/javascript">
var is_edit=document.getElementById('_acf_changed');
is_edit.value='1';
</script>

wp_insert_post not adding category

I'm building a WordPress theme where people can submit posts using wp_insert_post. The code below adds the post title but does not add the category specified by the user. Instead it puts it in uncategorized.
How do I get it to add the new category to the post when submitted?
if(isset($_POST['new_post']) == '1') {
$post_title = $_POST['post_title'];
$new_cat_ID = $_POST['category'];
//Checking if category already there
$cat_ID = get_cat_ID( $_POST['newcat'] );
//If not create new category
if($cat_ID == 0) {
$cat_name = array('cat_name' => $_POST['newcat']);
wp_insert_category($cat_name);
}
//Get ID of newly created category
$new_cat_ID = get_cat_ID($_POST['newcat']);
// Create post object
$new_post = array(
'ID' => '',
'post_title' => $post_title,
'post_status' => 'publish',
'post_author' => $user->ID,
'tax_input' => array( 'category' => $new_cat_ID )
);
// Insert the post into the database
$post_id = wp_insert_post($new_post);
// This will redirect you to the newly created post
$post = get_post($post_id);
wp_redirect( home_url() );
exit;
}
Here's the HTML for the form:
<form style="" action="" method="post" id="foo">
<input type="hidden" name="new_post" value="1"/>
<input type="text" name="post_title" value="title" id="input-title"/>
<input type="text" name="category" value="apples" id="category" />
<input type="submit" value="Login">
</form>
The category input should be:
<input type="text" name="newcategory" value="apples" id="category" />
In my tests, wp_insert_category did not work and wp_insert_term had to be used (as per this forum thread).
Your wp_redirect is not taking where you thing it does. The section //This will redirect you to the newly created post is plain wrong.
The following is a working example with a security layer added with wp_nonce_field, but you must add User Input Data Validation.
Also, I'm testing while logged in, so it works. Your code does not take care of $user->ID, research for get_current_user to get this right.
<?php
if ( isset( $_POST['noncename_so_17539370'] ) && wp_verify_nonce( $_POST['noncename_so_17539370'], 'nonce_so_17539370' ) )
{
if( isset($_POST['new_post']) == '1' ) {
//Checking if category already there
$cat_ID = get_cat_ID( $_POST['newcat'] );
//If not create new category
if( !$cat_ID ) {
$arg = array( 'description' => "my description", 'parent' => 0 );
$cat_ID = wp_insert_term($_POST['newcat'], "category", $arg);
}
// Create post object
$new_post = array(
'ID' => '',
'post_title' => $_POST['post_title'],
'post_status' => 'publish',
//'post_author' => $user->ID,
'tax_input' => array( 'category' => $cat_ID )
);
// Insert the post into the database
$post_id = wp_insert_post($new_post);
// This will redirect you to the newly created post
$post = ;
wp_redirect( get_permalink( $post_id ) );
exit;
}
} else {
echo 'ERROR';
}
?>
<form style="" action="" method="post" id="foo">
<?php wp_nonce_field( 'nonce_so_17539370', 'noncename_so_17539370' ); ?>
<input type="hidden" name="new_post" value="1"/>
<input type="text" name="post_title" value="title" id="input-title"/>
<input type="text" name="newcat" value="apples" id="category" />
<input type="submit" value="Login">
</form>

WordPress Radio Boxes - selects only the last one

So I have a form as shown bellow. its a bit long. It contains three radio boxes. Every time I select one, doesn't matter which, and then hit submit, the last radio element shows up as selected instead of the one I clicked. I var dump the option (in this case aisis_core['display_rows']) and it will say the value of the radio element i selected instead of the current on selected.
So I select lists, it will show lists but the radio box selected is no_posts. Can some one tell me what I am doing wrong?
<form action="options.php" method="post">
<input type='hidden' name='option_page' value='aisis_options' /><input type="hidden"
name="action" value="update" /><input type="hidden" id="_wpnonce" name="_wpnonce"
value="f0385965c6" /><input type="hidden" name="_wp_http_referer" value=
"/WordPressDev/wp-admin/admin.php?page=aisis-core-options&settings-updated=true" />
<fieldset>
<div class="control-group">
<label class="radio"><input type="radio" id="rows" class="display" name=
"aisis_core[display_rows]" value="display_rows" checked="checked" /> Display
posts as rows. </label>
<div class="control-group">
<label class="radio"><input type="radio" class="display" name=
"aisis_core[display_rows]" value="list" checked="checked" /> Display posts a
list. </label>
</div>
<div class="control-group">
<label class="radio"><input type="radio" id="noDisplay" class="display" name=
"aisis_core[display_rows]" value="no_posts" checked="checked" /> Display no
posts.</label>
<div class="no_posts_section borderBottom">
<div class="well headLine">
<h1>Display No Rows</h1>
<p>If you choose to display no rows please give me a url of the page or
content you would like to display instead.</p>
<p class="text-info"><strong>Note:</strong> Formatting of said content is
up you. All we do is display it.</p>
</div>
<div class="control-group">
<div class="controls">
<input type="url" name="aisis_core[index_page_no_posts]" value=
"http://google.ca" placeholder="Url" />
</div>
</div>
</div>
<div class="control-group">
<div class="form-actions">
<input type="submit" class="btn btn-primary btn-large" />
</div>
</div>
</div>
</div>
</fieldset>
</form>
The function I am using from wordpress is:
checked('radio_box_value', isset($options['display_rows']), false)
Note: radio_box_value is replaced with what ever the value of the radio box is.
In this case only the last radio box has the "checked" in it's tag, when it should be which ever one I chose.
How are the elements being created?
The following is how I create the elements, they print out what you see above in the html for the radio buttons. These are done similar to, but not exactly, zend framework.
Its pretty straight forward what were doing, create the element, add the options to the element and then return it.
I hope this gives a better picture as to how these are being created.
protected function _radio_rows_element(){
$options = get_option('aisis_core');
echo $options['display_rows'];
$radio_element = array(
'name' => 'aisis_core[display_rows]',
'value' => 'display_rows',
'class' => 'display',
'id' => 'rows',
'checked' => checked('display_rows', isset($options['display_rows']) && $options['display_rows'] == 'display_rows', false),
'label' => ' Display posts as rows. <a href="#radioRows" data-toggle="modal">
<i class="icon-info-sign"> </i></a>'
);
$radio = new CoreTheme_Form_Elements_Radio($radio_element, $this->sub_section_rows_array());
return $radio;
}
protected function _radio_list_element(){
$options = get_option('aisis_core');
echo $options['display_rows'];
$radio_element = array(
'name' => 'aisis_core[display_rows]',
'value' => 'list',
'class' => 'display',
'checked' => checked('list', isset($options['display_rows']) && $options['display_rows'] == 'list', false),
'label' => ' Display posts a list. <a href="#radioLists" data-toggle="modal">
<i class="icon-info-sign"> </i></a>'
);
$radio = new CoreTheme_Form_Elements_Radio($radio_element);
return $radio;
}
protected function _radio_no_posts_element(){
$options = get_option('aisis_core');
echo $options['display_rows'];
$radio_element = array(
'name' => 'aisis_core[display_rows]',
'value' => 'no_posts',
'class' => 'display',
'id' => 'noDisplay',
'checked' => checked('no_posts', isset($options['display_rows']) && $options['display_rows'] == 'no_posts', false),
'label' => ' Display no posts.</a>'
);
$radio = new CoreTheme_Form_Elements_Radio($radio_element, $this->_sub_section_now_posts_array());
return $radio;
}
"checked" function seems to need the value as second parameter as is explained here http://codex.wordpress.org/Function_Reference/checked
Try like this:
protected function _radio_rows_element(){
$options = get_option('aisis_core');
echo $options['display_rows'];
$radio_element = array(
'name' => 'aisis_core[display_rows]',
'value' => 'display_rows',
'class' => 'display',
'id' => 'rows',
'checked' => checked('display_rows', (isset($options['display_rows']))?$options['display_rows']:'', false),
'label' => ' Display posts as rows. <a href="#radioRows" data-toggle="modal">
<i class="icon-info-sign"> </i></a>'
);
$radio = new CoreTheme_Form_Elements_Radio($radio_element, $this->sub_section_rows_array());
return $radio;
}
protected function _radio_list_element(){
$options = get_option('aisis_core');
echo $options['display_rows'];
$radio_element = array(
'name' => 'aisis_core[display_rows]',
'value' => 'list',
'class' => 'display',
'checked' => checked('list',(isset($options['display_rows']))?$options['display_rows']:'', false),
'label' => ' Display posts a list. <a href="#radioLists" data-toggle="modal">
<i class="icon-info-sign"> </i></a>'
);
$radio = new CoreTheme_Form_Elements_Radio($radio_element);
return $radio;
}
protected function _radio_no_posts_element(){
$options = get_option('aisis_core');
echo $options['display_rows'];
$radio_element = array(
'name' => 'aisis_core[display_rows]',
'value' => 'no_posts',
'class' => 'display',
'id' => 'noDisplay',
'checked' => checked('no_posts', (isset($options['display_rows']))?$options['display_rows']:'', false),
'label' => ' Display no posts.</a>'
);
$radio = new CoreTheme_Form_Elements_Radio($radio_element, $this->_sub_section_now_posts_array());
return $radio;
}
This will not give warning when isn't declared the variable $options['display_rows'] (that as you said is a possibility in your case) and will pass the value to the WordPress function to compare with.
You'll want to check the value in the checked condition, not you're just checking if any value is being selected, which is always true after a submit
change
checked('display_rows', isset($options['display_rows']), false)
to:
checked('display_rows', isset($options['display_rows']) && $options['display_rows'] == 'display_rows', false),
and for the list to:
checked('display_rows', isset($options['display_rows']) && $options['display_rows'] == 'list', false),
I did manage to write this:
public function set_element_checked($value, $option, $key){
$options = get_option($option);
if(isset($options[$key]) && $options[$key] == $value){
return 'checked';
}
}
which does exactly what I want. compare the element value to that of the $option[$key] and if they match return checked. can be called via:
'checked' => set_element_checked('display_rows', 'aisis_core', 'display_rows');

Elementor breaks site with custom shortcode

I created a custom shortcode which includes a special loop which includes all posts from different multisite blogs. This solution is provided by this plugin: https://rudrastyh.com/. The shortcode is perfectly working an all normal pages and posts.
But I am also using the page builder Elementor. When inserting this shortcode into Elementor some strage things are happening: in editor mode the shortcode output is showing up twice, once at the top of the editor area and once again at the place where I actually put the shortcode. When I hit save, my whole site breaks and shows a standard image when accesing any page. Then the the only solution is to recover my latest database backup.
Here I show you some screenshots of the editor mode:
Here my shortcode fuction:
// Add Shortcode
function all_events_shortcode ($atts) {
// Attributes
$atts = shortcode_atts(
array(
'lang' => '',
'blog' => '',
),
$atts
);
// Network_Query parameters
$args = array(
'posts_per_page' => 14,
'blog_id' => esc_attr($atts ['blog']),
'lang' => esc_attr($atts ['lang']),
'orderby' => 'meta_value_num',
'order' => 'ASC',
'post_type' => 'noo_event',
'meta_key' => '_noo_event_start_date',
'meta_value' => date( "U" ),
'meta_compare' => '>'
);
$network_q = new Network_Query( $args );
// if there are posts, then print <ul>
if( $network_q->have_posts() ) :
echo '<div id="all_events">';
// run the loop
while( $network_q->have_posts() ) : $network_q->the_post();
// the get_permalink() function won't work without switch_to_blog()
// you can use network_get_permalink() instead but it is a little slower
switch_to_blog( $network_q->post->BLOG_ID );
// Get the dates
$start_date=get_post_meta($network_q->post->ID, '_noo_event_start_date', true);
$_start_date = gmdate("d.m.Y", $start_date);
$end_date=get_post_meta($network_q->post->ID, '_noo_event_end_date', true);
$_end_date = gmdate("d.m.Y", $end_date);
// you can obtain the post title from $network_q->post object
echo '<div class="all_events_item post-' . $network_q->post->ID . ' blog-' . $network_q->post->BLOG_ID . '">
<div class="all_events_img">
<a href="' . get_permalink( $network_q->post->ID ) . '">
'.get_the_post_thumbnail( $network_q->post->ID, 'large' ).'
</a>
</div>
<div class="all_events_content">
<h2>' . $network_q->post->post_title . '</h2>
<br />
<span class="start_date">'.$_start_date.'</span> -
<span class="end_date">'.$_end_date.'</span>
</div>
</div>';
// restore_current_blog() to switch to the previous (!) website
restore_current_blog();
endwhile;
echo '</div>';
endif;
network_reset_postdata(); // add it after the loop if you plan to use Network_Query multiple times on the page
}
add_shortcode('all-events', 'all_events_shortcode');
Can you give me some hints how I could tackle this problem?
Best wishes
Try this, it helped me.
Adding ob_start(); and then ob_get_clean();
function function_name(){
ob_start();
//..your code here...
$content = ob_get_clean();
return $content;
}
add_shortcode('shortcode_name','function_name');
Found the solution here and tried it. It worked for me.
Elementor page builder shortcode issue
Original credit: https://stackoverflow.com/a/48813883/9364624
Posted By: https://stackoverflow.com/users/1753934/colin-oakes
You need to bind HTML in variable and then return this HTML from shortcode..
Please check the code below
function _login_popup() {
$html = '<form id="user-login-form" method="post" action="#" class="js-form-redirect js-form-action" novalidate="">
<div class="floating-label form-group">
<input id="useremail" name="user_name" required="" value="" type="email">
<label for="useremail">Email</label>
</div>
<div class="floating-label form-group">
<input id="userpassword" name="password" required="" value="" type="password">
<label for="userpassword">Password</label>
</div>
<div class="o-form__buttons text-right --small-center">
<button type="submit" id="submit_login" class="a-button-form --save a-no-before" value="edit">Sign in</button>
</div>
</form>';
return $html;
}
add_shortcode('yg-login-popup', '_login_popup');
In this shotcode i have created login form..

Resources