Build a Simple User Logged In Shortcode in WordPress

Posted by | Basic Coding, WordPress | No Comments

Sometimes it is useful to display further content only to logged in users. A very simple way of doing this is to build a user logged in shortcode.

This means that when you are editing your content, you can add something like:

[loggedin]This content will only be displayed to logged in users.[/loggedin]

There are plugins that can offer this kind of thing but you can add it to your theme yourself very easily.

If you are looking for the best place to host your WordPress site, knowing that it will run very fast and always be secure, be sure to check out WPEngine

A Simple User Logged in Shortcode in WordPress

Open up your functions.php file in your theme and add the following code:

function check_user ($params, $content = null){
  //check tha the user is logged in
  if ( is_user_logged_in() ){

    //user is logged in so show the content
    return $content;



    //user is not logged in so hide the content



//add a shortcode which calls the above function
add_shortcode('loggedin', 'check_user' );

And there you have it, you can then write something like:

[loggedin]This content will only be displayed to logged in users.[/loggedin]

…and it should work.

Tracking Google Adwords Conversions in Contact Form 7 for WordPress

Posted by | WordPress | No Comments

Contact Form 7 is a fantastic WordPress plugin which simplifies the boring task of building forms on your WordPress website.

The out-of-the-box install uses an AJAX form submission. This means that users don’t get redirected to another page on your website following a form submission. Instead they are just shown a thank you message ¬†within the same page.

This is ideal for users as it makes it smooth and painless. However, this also means that there is no thankyou.html page where you can add your conversion tracking code for Google Adwords.

Read More

Have a project that you want to talk about? Get A Quote