How to add/remove user role in wordpress

For role add use below function

$aRole = "Your role name";
$aDisplayName = "Role display name";
$aCapabilities = array();
add_role( $aRole, $aDisplayName, $aCapabilities );

For role remove user below function

$aRole = "Your role name";
remove_role( $aRole );
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

Post data using curl

$aUrl = '####';
$aData= array('key1' => 'val1','key2' => 'val2');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($aData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

Preview and Download Html2Canvas

Here is the code for converting html into canvas.

When we click on Preview button canvas will be show and click on Download canvas will be save in .png format.

<!DOCTYPE html>

<!-- include jquery.min.js and html2canvas.js -->
  <script src="jquery/3.1.1/jquery.min.js"></script>
  <script src="jquery/html2canvas.js"></script>

    background-color: #9E9E9E;
    color: #fff;
    padding: 5px 0px 27px 30px;
    width: 46%;
    margin-bottom: 15px;
input#PreviewImage {
    margin-bottom: 15px;

    var getCanvas;
    function callCanvas(){
    html2canvas($("#previewBody"), {
    onrendered: function(canvas) {
    getCanvas = canvas;
   $("#PreviewImage").on('click', function () {
   $("#downloadimage").on('click', function () {
      var imgageData = getCanvas.toDataURL("image/png");    
    // Now browser starts downloading it instead of just showing it
    var newData = imgageData.replace(/^data:image\/png/, "data:application/octet-stream");
    $("#downloadimage").attr("download", "your_pic_name.png").attr("href", newData);
<div id="previewBody">
  <h2>CANVAS Example</h2>
  <p>Click on preview will show canvas </p>
  <p>Click on download will download the canvas in .png format</p>
        <input id="PreviewImage" type="button" value="Preview"/>
        <a id="downloadimage" href="#">Download</a>
        <div class="preview_Canvas">

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

Import large csv data into Mysql within seconds.

Here is the PHP script that will import your large CSV file data within seconds .

1. Copy the below code and paste into your file and save your file with “.php” extension or you can download file directly from here.
2. Copy your csv file and paste into the same folder where your php file exists.
3. Now run your php file in browser.
4. Browser will show a form with some fields . you have to fill your database and table details and in “Name of the file” field you have to fill your csv file name.
5. Click on submit button.

It will take some seconds and your all csv data will import into your mysql table.


$password= '';
$cons= mysqli_connect("$sqlname", "$username","$password","$db") or die(mysql_error());
$result1=mysqli_query($cons,"select count(*) count from $table");
//If the fields in CSV are not seperated by comma(,)  replace comma(,) in the below query with that  delimiting character 
//If each tuple in CSV are not seperated by new line.  replace \n in the below query  the delimiting character which seperates two tuples in csv
// for more information about the query
mysqli_query($cons, '
    LOAD DATA LOCAL INFILE "'.$file.'"
        INTO TABLE '.$table.'
        FIELDS TERMINATED by \',\'
        LINES TERMINATED BY \'\n\'
')or die(mysql_error());
$result2=mysqli_query($cons,"select count(*) count from $table");
echo "Success";
echo "<b> total $count records have been added to the table $table </b> ";
echo "Mysql Server address/Host name ,Username , Database name ,Table name , File name are the Mandatory Fields";

<title> csv2 sql</title>
<link rel="stylesheet" href="//">

<form class="form-horizontal" action="" method="post">
    <div class="form-group">
        <label for="mysql" class="control-label col-xs-2">Mysql Host name</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="mysql" id="mysql" placeholder="">
    <div class="form-group">
        <label for="username" class="control-label col-xs-2">Username</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="username" id="username" placeholder="">
    <div class="form-group">
        <label for="password" class="control-label col-xs-2">Password</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="password" id="password" placeholder="">
    <div class="form-group">
        <label for="db" class="control-label col-xs-2">Database name</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="db" id="db" placeholder="">
    <div class="form-group">
        <label for="table" class="control-label col-xs-2">table name</label>
        <div class="col-xs-3">
        <input type="name" class="form-control" name="table" id="table">
    <div class="form-group">
        <label for="csvfile" class="control-label col-xs-2">Name of the file</label>
        <div class="col-xs-3">
        <input type="name" class="form-control" name="csv" id="csv">
        eg. yourfile.csv  (Your file must be in same folder where this script exist)
    <div class="form-group">
    <label for="login" class="control-label col-xs-2"></label>
    <div class="col-xs-3">
    <button type="submit" class="btn btn-primary">Upload</button>

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

Installing laravel on ubuntu step by step

Follow the following steps exactly to installing laravel on ubuntu operating system

Basic Need :

  1. apache server installed
  2. php 5.8 and above
  3. internet connection
  4. Root permission for terminal

// notice: in these steps i had use “brijesh” an an example for project name you can user your own porject name by replacing it with yours.

Step1: First install composer

user this link if needed more information // refference:

        use these command for installing composer

sudo php -r "copy('', 'composer-setup.php');"
sudo php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

// to un install composer
php -r "unlink('composer-setup.php');"

Step 2: Change root directory path (if your server folder is “html” then goto html folder

cd /var/www/html

Step 3: Install Laraven with your project name ex.: brijesh

composer<em> create-project laravel/laravel your-project-name</em>

ex.: composer create-project laravel/laravel brijesh

step 4: Give permission to brijesh , App, Storage , Piublic

sudo chmod -R 755 /var/www/html/brijesh
sudo chmod -R 777 /var/www/html/brijesh/app
sudo chmod -R 777 /var/www/html/brijesh/storage
sudo chmod -R 777 /var/www/html/brijesh/public

Step 5: create virtual host

// copy and past default host file by below comand to your { PROJECT NAME }<em></em>
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/brijesh.conf

// edit your .conf file
sudo vim /etc/apache2/sites-available/brijesh.conf

// Add this code  { replace brijesh with your project name } save and exit

<VirtualHost *:>
 ServerAdmin admin@brijesh
 DocumentRoot /var/www/html/brijesh/public/index.php

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

 <Directory /var/www/html/brijesh>
 AllowOverride All


// then press Esc and then write :wq and enter button end

Step 6: enable your vitural host

sudo a2ensite brijesh.conf
sudo service apache2 restart
 Step 7: change host url
// open host
sudo vim /etc/hosts

// there look like localhost 
 // add your host name like
 //save, exit and restart apache
sudo service apache2 restart


Type in url “” or “localhost/brijesh/public/index.php” 

if below screen appears

yo yo laravel starts woooo……….

notice : replace brijesh with you project name.


while installing laravel on ubuntu operating system if there is any problem please comment we will reply as soon as possible thanks.

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone