30 November 2019

How to remove required attribute from text field with jquery?

 Remove required attribute from text field with jquery




$('#enterpassword').removeAttr('required');

$("#enternumber").removeAttr('disabled');

28 November 2019

How to get all months in php?

Get all months in php                            





for ($m=1; $m<=12; $m++) 
{
$month = date('F', mktime(0,0,0,$m, 1, date('Y')));
                                     echo $month;
                               }

How to get all unique years from a date column using Sql(Mysql)?

 Get all unique years from a date column using Sql(Mysql)?



SELECT distinct year(OrderDate) FROM Orders;



SELECT distinct year(column_name) FROM table_name;

How to get previews years from current year in php?


Get previews years from current year in php



<?php
echo date("Y",strtotime("-1 year"));
 ?>

25 November 2019

How to redirect after login (login_redirect) based on user role in wordpress?

Redirect after login (login_redirect) based on user role in wordpress


function my_login_redirect( $redirect_to, $request, $user ) {
    //is there a user to check?
    global $user;
    if ( isset( $user->roles ) && is_array( $user->roles ) ) {
        //check for admins
        if ( in_array( 'administrator', $user->roles ) ) {
            // redirect them to the default place
            return $redirect_to;
        } else {
            return home_url('/my-profile/');
        }
    } else {
        return $redirect_to;
    }
}

add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

13 November 2019

How to Create a Custom Page in WordPress?

<?php /* Template Name: myfirstpage */ ?>
 
<?php get_header(); ?>
 
<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">
        <?php
        // Start the loop.
        while ( have_posts() ) : the_post();
 
            // Include the page content template.
            get_template_part( 'template-parts/content', 'page' );
 
            // If comments are open or we have at least one comment, load up the comment template.
            if ( comments_open() || get_comments_number() ) {
                comments_template();
            }
 
            // End of the loop.
        endwhile;
        ?>
 
    </main><!-- .site-main -->
 
    <?php get_sidebar( 'content-bottom' ); ?>
 
</div><!-- .content-area -->
 
<?php get_sidebar(); ?>
<?php get_footer(); ?>

How do you round to 1 decimal place in Javascript (roundup)?

Round to 1 decimal place in Javascript (roundup)


var number = 12.3456789;
var rounded = Math.round( number * 10 ) / 10;
// rounded is 12.3

How to create video slider with cuncks of videos without download all videos?

 Create video slider with cuncks of videos without download all videos function custom_video_slider_shortcode() { $slider_id = 'vide...