My working experience at WPMU DEV

WPMU DEV is one of the leading WordPress based product and service companies; and also where I have been working since 2013. From the beginning, WPMU DEV has contributed a lot to the WordPress community. Besides, they have some awesome products and services like Hustle, Hummingbird, Defender, WP Smush Pro, WP Academy, a really awesome drag and drop theme builder – Upfront, Upfront Builder (with which you can create your own theme and sell it in a marketplace with zero or little coding knowledge), and many more.

Incsub LLC is the parent company of WPMU DEV. They are also the parent of CampusPress and Edublogs. They are also going to introduce WordPress Managed Hosting very soon.

There are 70+ members working in this team across the world and I am really proud to be part of this giant team. I am sharing my WPMU DEV Journey.

I was not a WordPress guy back then. I had been working remotely in a UK based company Web Media 360 who mainly work in SharePoint platform where my role was to make connection between backend and frontend. I was responsible to fetch data from several SharePoint lists and then display it on the frontend. They have some big companies like Vodafone as their clients; however, it still was not my field. I am a php lover, and had already developed several applications in CodeIgniter – so was looking for an opportunity to switch into my field. We have a facebook group that consists of 20000+ active members called WordPressians where I was an active member (currently I am one of the proud admins of that group). One of my friends, Emran Ahmed posted a job circular in that group – the circular was about WPMU DEV looking for a WordPress developer. Back then, I hardly heard about WordPress. I had a lot of experience with Joomla, but WordPress? Sadly, no! But I still decided to give it a try.

I took a challenge of 7 days to learn WordPress as much as I can and develop a plugin for the job interview. At the seventh day, I developed a Meet the Team plugin and submitted with my job application to WPMU DEV.

James Farmer

It took around a week to get a reply from James Farmer, CEO of Incsub LLC. That was really a surprise, an email asking my preferred time for an interview. I could not wait, so I wanted it ASAP. Later that day, he gave me one of their existing plugins – Pro Sites and asked me to develop a new module for that plugin. Here comes the funny part!

I have installed the plugin in my fresh WordPress site and found it not working. I just thought if they were making fun. I went to Pro Sites product page and found the plugin is only Multisite compatible. I was just like – What the heck was Multisite? I applied for a WordPress developer role, not Multisite or bla bla bla. But still I asked one of my best friends, Google, and he told me that Multisite is a feature of WordPress. Alas! I never heard of that!

I started learning Multisite at 9pm, setup Pro Sites in my first Multisite and developed the module for the plugin. I sent them back at 5am. And in an immediate reply I was introduced to Aaron Edwards, CTO of the company who would review my code and send feedback.

Aaron Edwards

The next day I got an email from Aaron asking some questions:
1. To develop the new module why I have followed exact same pattern of an existing module?
2. Why didn’t I use l10n?
3. Why didn’t I use i18n?
and about some more basics mistakes as well.

Answer of #1 was ready – as I am going to add a new module, so I thought I should have followed the project pattern and that is how I should implement.

For number #2 and #3, the sky had fallen on my head l10n, i18n – which language is that? Again I went to Google and learned the terms – localization (10 characters between l and n), internationalization (18 characters between i and n). I had completely no idea about those. I am honest so I admit that. I clearly mentioned that I had no idea about those, I just learned them and I believe I can implement that in my next task.

Now again it’s waiting time. Next week got an email from James mentioning that I am not a good fit for the developer role at WPMU, but he still wants me to tryout in their support team. He offered me a handsome working rate, but still there is a barrier.

Timothy K Bowers

I have to face another interview with the support team lead – Timothy Bowers – Tim. Tim was funny but always mysterious. When I first had a chat with him, it seemed he was always angry and fed up with everything in the world! This was a three steps interview, which started with some conversation – where he asked me some basic questions about me, my works, personal life etc. In second step he gave an open question set and in third step there was a secret question set. The duration of each QA interview was one hour. And the next day he offered me a 30 days trial with WPMU DEV. The date was August 27th, 2013.

Tyler Postle

It was like dream come true. I worked hard and tried my best during my trial and in 17th day Tim made me permanent. That was the shortest trial until later on Tyler had the shortest trial – 5 days, Tyler is awesome!

The journey began. The entire team is really awesome. I got some cool colleagues, or you can call it friends. The team leader, Tim, whom I thought the most boring guy in the world, became the most entertaining guy to me very quickly. He is really a great team lead and he knows very well how to handle his team members. He treats every member exactly the right way so they feel comfortable. As I was totally new in WordPress, he helped me a lot to get familiar with the eco-system. Back then, there was Jack and PC who were my buddies and guided me very well which made me Ash from Ashok. I have got some more friends too like Michelle, Tyler, Bojan, Rupok (He is from Bangladesh), Philipp, Nastia, Panos, Kasia, George, Vaughan and more – I can’t remember everyone’s name right now – sorry guys!

Some of my cool colleagues here:

Nastia

Bojan Radonić

Rupok Chowdhury

Predrag

Panos

Michelle Shull

Kasia

Vaughan

George

Like any other normal human being, I had difficult time in WPMU DEV. And in that time, Tim took my personal care, he took several sessions with me, suggested me over DM as he didn’t want to lose me and I followed all of his advice as I didn’t want to make him down, and I overcame. Slowly I moved into development but I never left the support team and didn’t want to join full time as a developer. Because I really love the very friendly support team. We share lots of personal interests among ourselves. It’s like a family.

After having some experience with WordPress, Tim was pushing me to do more dev works. So I got involved into second level coding support, bug fixes, hot fixes and later I working on two major plugins – Membership 2 and Events+ (don’t consider me as lead developer of those plugins please 🙂 ). I have also worked as a QA, tester, team lead for a short time and now as a buddy lead.

But at the end of day, I still consider myself as a support star! I like helping people, very passionate when it comes to solving their problems and love to take on new challenges. Sometimes I got angry members and learned how to keep them calm satisfying their needs. It makes me happy when I can imagine smile on the member’s’ face. It’s an achievement when a member asks a question in the support forum specifically requesting me to reply on their ticket. That really makes me happy and proud.

I have attended my first WordCamp in 2014 at Baroda, India and my tour was sponsored by WPMU DEV. Unfortunately I have met only 3 of colleagues so far. Tim always pushes me to join in a WordCamp Europe, but I never could make it due to my personal issues (Family gets priority you know).

However, it’s been more than 3 years I am here. I don’t know how long the journey will continue, but I am sure as long I am here, I am one of the happiest staffs in the world.

WPMU DEV is not just a company… it is a team, and a family!

You can reach me here: Facebook, Twitter, Linkedin, Email

If you have any question, feel free to comment below.

Easiest but powerful encryption in PHP

For a secured system, most of the data is encrypted in server end and sent to database. And after fetching the data from database, just decrypt before showing in front end.

There are lots of procedure to encrypt the data, lots of encryption algorithm out there. But, here we will use a simple encryption method though it’s powerful 🙂

We are going to use mcrypt library of php for this method. You can install the library following the instruction below: (based on Ubuntu)

Once you install mcrypt, you are free to use the library. Here is the code that you need to include in your project:

[gist https://gist.github.com/bappi-d-great/f5884c095b663ea90b27277f33b1e998]

The usage is already in the above gist. But again, just instantiate the class, pass the data you want to encrypt, do whatever you want. Then when needed, fetch and decrypt:

Happy coding! 🙂

Gulp tutorial for beginners

In a sentence, Gulp is a task runner.

Gulp makes our life easier. In a development workflow, we need to do some tasks frequently and gulp can do some tasks automatically. Don’t think gulp is a replacement of grunt, but it is being improved very very fast.

Gulp is a task/build runner for development. It allows you to do a lot of stuff within your development workflow. You can compile sass files, uglify and compress js files and much more. The kicker for gulp is that its a streaming build system which doesn’t write temp files.

In this article, I will show you to create a simple WordPress plugin taking advantage of gulp. I am using MAC OS (OS X Yosemite) and MAMP as server.

We will compile sass to css, minify it, concat all the css files into one file, uglify js, concat all js files into one file, run these on changes automatically, create po file for i18n and create the release package as zip.

Let’s start!

First, look at my directory structure:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”0-directory-structure.txt” /]

In here, index.php is our main plugin file. There are three sass file in scss folder, which will be converted into css where gulp.main.css is the css file and gulp.main.min.css is the minified version. Exactly same for js script as well, gulp.main.min.js is the minified/uglified version of gulp.main.js which is a combination of ajax.js and public.js files. In the lang folder, we will generate out po file. node_modules folder will be auto generated, so is package.json file (we will see), the packages will be in there. We will use the releases folder to store the plugin package as zip. gulpfile.js file is our gulp configuration file.

Install Gulp

You must need Node JS and Node Package Manager (NPM) in your host to use Gulp. If you don’t have yet, please download from their site.

If you have those, let’s install gulp globally that will help us to run the gulp command anywhere in your system.

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a1-install-global-gulp.txt” /]

I assume you are already in root of the plugin directory in terminal.

Initializing gulp

Run the following command:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a2-init-npm.txt” /]

This command will create a package.json file and it will look like:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a3-package.json” /]

The command will ask you some question, you can leave to default just pressing enter or you can configure.

Now, we have to install dependencies. Of course, the first dependency is gulp itself:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a4-install-gulp-locally.txt” /]

The –save-dev flag asks to install the dependencies locally and you will see the updated package.json file with this dependency.

Now, let’s create gulpfile.js file manually, the file name is strict.

Hello World(?) in Gulp

Open the new created gulpfile.js and start configuring. We have just installed a dependency and to use every dependency, we need to use require function.

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a5-configure-gulpfile.js” /]

As we know, gulp is a task runner, so we will define some tasks, and gulp will run those tasks. The format of a task declaration is simple:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a6-define-gulp-task.txt” /]

So, create our first task:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a7-gulp-task-example.txt” /]

And run just “gulp mytask” in the terminal. Please note, in the command example first gulp is my plugin folder name, please do not get confused, sorry for that.

The “gulp mytask” will show the output like:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a8-gulp-mytask-output.txt” /]

If we want to use more dependencies (of course we will use), then the default format should be:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”a9- gulp-default-example.js” /]

Here, src function is used to get the source file, pipe function is used to bind with the dependency functions and dest function refers to the destination folder.

Let’s compile SASS

We have learnt about gulp, now let’s do a real task. We will compile sass file and for that we will need to install a dependency:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b10-install-gulp-sass” /]

Add in gulp js file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b11-sass-gulpfile.js” /]

Write the task:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b12-sass-gulp.js” /]

Write some sass file in about.scss file like:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b13-demo-sass.scss” /]

Now run “gulp sass” in the terminal and you will see the generated css file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b14-output-new.css” /]

Please check, in the task, the task name is sass, so we called “gulp sass”, gave the source file in src function, then used pipe function to run sass dependency function, and then sent to the destination.

This is done for one file, what if we have multiple files? We can do is very easily:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b15-sass-multiple-files-gulp.js” /]

Now, if you have 3 sass files, it will generate 3 css files. But we want to combine all those. So, let’s install contact dependency:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b16-general-single-css-file-from-multiple-sass-file.txt” /]

And add code in gulp js file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b17-gulp-with-contact.js” /]

See, in pipe function, I used concat funtion and gave a file name. All the css files will be combined and get name gulp.main.css and then sent to the destination folder.

Our next job is to minify the generated css, so install minify module:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b18-minify-css.txt” /]

Add code in gulp file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”b19-gulp-with-minify.js” /]

This is all similar, here I have also mentioned to make compatible to IE8, that’s totally optional.

Let’s do some auto-prefixing job. Like, if you use “display: flex” in your sass file, it will create all the prefixer for that like – -webkit-flex, -ms-flex etc, cool – heh?

So, install auto-prefixer:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c20-auto-pre-fixer.txt” /]

Add in gulp file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c21-gulp-with-pre-fixer.js” /]

Another interesting thing, we are going to add – sourcemap. This is very interesting. To debug css, we always use the browser developer toolbar. But when you use sass to write your css, then in browser inspector, you will see reference to css not sass file. Sourcemap will help you to see the reference of sass file, like the screenshot below:

sm

Install sourcemap then:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c21-using-sourcemap.txt” /]

Configure in gulp file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c22-gulp-with-sourcemap.js” /]

We are almost done. Just one thing, after doing minify we need to rename the file to with some suffix, like .min. We will use rename module:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c23-rename-file.txt” /]

And now configure:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c24-gulp-with-rename.js” /]

Please note, in a step I renamed the task name to “build-css”. So, now run in the terminal “gulp build-css” and see the magic! The minified version and combined version will be generated in the css folder.

As we are familiar with the process now, I will go little faster, if any confusion, please comment below.

Let’s play with JS now

For JS files, we will do almost similar things, except we will uglify instead of minify. It’s same but uglify minifies the variable name and do other compression too.

Install uglify then:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c25-uglify.txt” /]

And in gulp file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c26-gulp-uglify.js” /]

Now, run “gulp build-js” in terminal and see the output files in js folder.

Do the above jobs on the fly!

Till now, what we have done, if we make any changes we will need to run the command and check in the browser. How’s about doing it more automatic? Like we will make changes, save and right then the above task will be completed. We will ask gulp to watch for any changes, and if any changes found, run the above two tasks.

We will use “watch” command to ask gulp to watch changes.

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c27-gulp-watch.js” /]

Check at the very bottom, I have defined the watch task which will watch all css and js files for changes and run the corresponding task.

Create po file

In WordPress, we need to provide po file to the users, so that they can translate the strings in their language. We normally use poedit or glotpress to do this job. But now, we will run a php shell command using gulp.

To do that, we will use WordPress’ makepot tool. So, download the wp-dev using svn:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”d31-mkpot-tool.txt” /]

And the gulp task will be:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”d32-pot-gulp.js” /]

Here, /Users/ashokkumarnath/Desktop/pot/wp-dev/tools/i18n/makepot.php is the path to makepot.php file which will create the po file. Please replcae the path with your file path.

wp-plugin is used for plugins, if you are developing a theme, use “wp-theme”.

Then the folder name “lang”, in my case, and the text-domain gtd.po. Change gtd with your text-domain.

Now run “gulp i18n” and see the po file is generated in lang folder.

Final touch and release the plugin!

Now, we will copy the files we need for the plugin and paste to releases folder, under the version name:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c28-gulp-copy-to-release.js” /]

The created task name is “build” here. We have asked to copy index.php and recurrsive assets folder into releases/VERSION_NO/ folder.

In last step, we will create zip of the plugin, so we will need zip module:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”c29-zip-module.txt” /]

And create the zip task:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”d30-gulp-zip.js” /]

You will see at the bottom, I have created a default task for gulp. The default task will run when you command just “gulp” in the terminal. So, when “gulp” command is run in terminal, I have set ‘build-css’, ‘build-js’, ‘build’, ‘zip’ – all four tasks to be run.

Now, if you just run “gulp”, it will compile the sass, create css, combine, create minify version, combine js files, create minified js file, create po file, copy the plugin files and create the releasable zip.

I have done some more polishing in my final gulpfile.js file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”e-final-gulpfile.js” /]

In line 65, I asked to run build task only when build-css and build-js tasks are done, not before that. In line 73, the zip task will run, when the build task is done. This is called task dependency.

So, when you will work on css and js, before start working run “gulp watch” in the terminal, do not break/cancel it so that it can run the build-css and build-js when you make some changes. When you are done, just run “gulp”.

This is the final version of package.json:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”e-final-package.json” /]

This is the final version of main plugin file:

[gist https://gist.github.com/bappi-d-great/598699df608ce13bbb3c file=”e-final-plugin.php” /]

It may look like little complex, but once you practice 2-3 times, it will be very very easy.

So, be automatic! 🙂

How to use SSL in localhost

There are lots of stuffs we need to test with SSL. There are some SSL providers that provide free SSL we can use those in our site. Among free SSL providers, I prefer to use CloudFlare, it’s very easy to use and nothing to setup though it needs ~24 hours to activate. Also, developers from countries where we don’t have super high speed internet, we are used to work in locally hosted site. So, usually we can’t use SSL in local site – in other words most of the developers doesn’t know. But it’s possible, and even it’s not complex at all!

SSL (Secure Sockets Layer) is the standard security technology for establishing an encrypted link between a web server and a browser. This link ensures that all data passed between the web server and browsers remain private and integral.

There are many ways to enable SSL in localhost, specially if you use MAMP PRO, then it is just a matter of couple clicks. Today, I will show you to use SSL in VVV. Just for your information, we are not buying any SSL certificate, it will be self signed certificate.

The self-signed SSL certificate is generated from the server.key private key and server.csr files. The server.crt file is your site certificate suitable for use with Heroku’s SSL add-on along with the server.key private key.

I assume you are already familiar with Vagrant and VVV. I am using a customized version of VVV in MAC OS, so the folder path could mismatch but that should not be any problem. I am also using VVV Site Creation Wizard to create and delete site with a couple of commands, it’s really very handy. It also creates vhost file in VVV disk and edit the host file in your OS. So, just command and start using the new site!

Let’s open the terminal and navigate to your vagrant directory and create a site:

[gist https://gist.github.com/bappi-d-great/261fcf356fa68105e8c6 file=”create-new-site.txt” /]

It will ask you site name, domain, if it will be a single wp site or multisite etc, should take 2-3 mins. I assume, the domain you selected is http://sslsite.dev. Now. let’s navigate to nginx config folder and create SSL directory:

[gist https://gist.github.com/bappi-d-great/261fcf356fa68105e8c6 file=”create-ssl-directory.txt” /]

Now, we need to generate our self-signed cert and key file, let’s do it:

[gist https://gist.github.com/bappi-d-great/261fcf356fa68105e8c6 file=”generate-ssl-certificate-and-keys.txt” /]

Add the cert and key file reference in the sslsite.dev configuration file:

[gist https://gist.github.com/bappi-d-great/261fcf356fa68105e8c6 file=”edit-configuration-file.txt” /]

You must replace vvv_path_to_folder with the correct folder path, it may vary. Below is the my configuration:

[gist https://gist.github.com/bappi-d-great/261fcf356fa68105e8c6 file=”vvv-path-to-folder-directory.txt” /]

Easier to find if you just login at your vagrant using ssh and check the location. Now as the last step, run a single command:

[gist https://gist.github.com/bappi-d-great/261fcf356fa68105e8c6 file=”vagrant-provision.txt” /]

We are all done, hurray!

We still have a small problem. When you run the site https://sslsite.dev (with https) the browser will show that the site is not trusted. To avoid this, let’s add the cert file into your keychain. Open your keychain access window, in left sidebar select “System” for keychains and select “Certificates” for category, like the following screenshot. Now just drag the cert file and drop into the right panel of the window.

keychain

You are completely all set. Start playing around with SSL in your local machine!

Happy New Year!

How to apply coupon automatically on WPMU membership2 checkout

Membership 2 is an awesome plugin to sell your content. That being said, you can charge your members to see your site content.

If you want to give discount, you can use Coupon addon. You have to enable from Membership 2 > Addons and then you can create coupons and share with your users. Today I will show you a trick to share coupon embedded with URL. You can share your URl like http://domain.com/?coupon=XXXX and the XXXX coupon will be automatically applied on checkout.

Let’s look at the code:

https://gist.github.com/bappi-d-great/dcc54b72afaf9e6c44f7

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

Assign and withdraw role on an user based on membership – WPMU Membership2

WPMU Membership2 plugin has an addon that you can use to assign extra capabilities to an user when he joins in a membership, and when the user left the membership the capabilities are withdrawn. But, the problem is, even it says “Assign role”, it doesn’t assign role to that users but just assign the capabilities of that role.

So, if you need members of certain role, you won’t get those members in the member list. Even, if you have other plugin that makes some operation based on role, won’t work here. Let’s find a solution.

The following snippet will allow you to set different role based on membership, you will need to know membership IDs though. In the following example, if ID is 1343, I want to assign those users “editor” role, “author” for 1345 and “administrator” for 1348. Take a look:

https://gist.github.com/bappi-d-great/794bd6a18eecb59f8f27

Now, if the user’s membership is deactivated or cancelled, we need to assign back “subscriber” role to that user. I have used same code for cancel and deactivation operation, you can assign different role if you want:

https://gist.github.com/bappi-d-great/cf1c337e5b7cdba77eb3

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

Assign a membership to a registered member automatically – Membership 2 (WPMU)

WPMU DEV has released the new revamped version for membership plugin, called Membership 2. The layout and interface is awesome of the plugin and I am personally impressed. There is a new type of membership introduced in the plugin – Default Membership. This membership will work for the user who are just registered but didn’t choose any membership to join.

But what if you want to assign a regular membership to that user? Here is a simple code snippet that will help you to do this job:

https://gist.github.com/bappi-d-great/a50ab3599273a2308e2e

Just make sure you change to correct membership ID for $membership_id variable.

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

How to add an user into a BuddyPress group automatically when he joins in a WPMU membership

This is an useful snippet that will add your newly registered (via WPMU DEV Membership 2) member to corresponding BuddyPress group.

https://gist.github.com/bappi-d-great/28764839a18115a66a1d

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

How to use custom post type archive as front page

We can easily set any page as front page from Settings > Reading. It can be any static page. But what if we want to set an archive or CPT archive page as front page?

There are many ways to do so. We can create a custom page template, and write our code to get the posts for the post type (will look like an archive). Then create a wordpress page using that page template and select that page as front page from Settings > Reading.

This is a little complex if you are not a developer. Or even if you use a custom theme. Let’s do it in another way.

What you need is to have a file inside your theme for archive – archive.php. For CPT the file name will be archive-{CPT}.php. We will use the same file to make our home page.

For example, if your CPT archive url is http://domain.com/my_cpts then we want to see exact same layout and same content of http://domain.com/my_cpts in http://domain.com/.

What I love to do in this case is to use a very simple snippet. Where I just need to set the CPT name, that’s it. Here is the code:

https://gist.github.com/bappi-d-great/f06ca7dbe37d860337fe

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

Note that, here CPT means Custom Post Type

Enjoy!

Defer parsing of javascript to improve performance in wordpress

Nothing for introduction, hehe! A very small snippet which will help you to defer parsing all javascript files except jquery in wordpress. Here is the code:

https://gist.github.com/bappi-d-great/2a67ff307db672d4566b

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.