Creating design for smartphone users

Do you want to manage a set of resources internally and want to create an intranet for this purpose? Do not struggle, WordPress can be the solution. Indeed, the WordPress management platform, which is the most popular, offers a set of tools that you can exploit. We have also used our expertise to develop an intranet extension. In this article, we explain how to turn WordPress into an intranet. We will propose you two approaches: an approach for developers (without extension) and an approach with extension (plugin).

Turn WordPress into an intranet without a plugin

If you have web development skills, turning your website into an intranet may require a few lines of code. We will see below how to do this. Nevertheless, it is essential to mention that the use you have for it depends on the need. For example, companies may need an intranet to manage documentation in-house. For others, the need might be an online training portal. Thus, the approach you will use will be guided by your need. In the following, we will look at a few lines of code to make WordPress content private.

1 – Create a URL redirect to send visitors back to the login page

To achieve this, you must have some knowledge of PHP. Then you can either create a custom login page using the wp_login_form function, or you can simply redirect your users to the WordPress login page. Below are some sample codes you can use.


<?php
/**********************************************
 *         Option for a custom login Page
 * 
 * *************************************/
 
 
function redirect_non_logged_in_users() {
    $login_id = 10; 
    $registration_id = 11;
    if (!is_user_logged_in() && !is_page($login_id) && !is_page($registration_id)) {
        wp_redirect(get_permalink($login_id));
        exit;
    }
}
add_action('template_redirect', 'redirect_non_logged_in_users');



/**********************************************
 *  redirect users to the default login
 * 
 * *************************************/
 
 
 function redirect_non_logged_in_users() {
    if (!is_user_logged_in()) {
        wp_redirect(wp_login_url( get_permalink() ));
        exit;
    }
}
add_action('template_redirect', 'redirect_non_logged_in_users');
?>

In the codes above, we have two examples you will encounter. Indeed, the first case is where you want to have a custom page. However, in the second case, users will be redirected to the default WordPress login page.

If you are using a custom page to log in to your WordPress website, you can, for example, create a shortcode to display the login form on the login page. The code below is an example.

2- use the wp_login_form function to add the form to a custom page

with this feature, you can create a shortcode that will run on the login page. The next step will then be to replace the link to the default login page with the link to your page. In this case, you can exclude the login page from the redirect (See the first function).

function redirect_non_logged_in_users ( ) { $login_id = 10 ; $registration_id = 11 ; if ( ! is_user_logged_in ( ) && ! is_page ( $login_id ) && ! is_page ( $registration_id ) ) { wp_redirect ( get_permalink ( $login_id ) ) ; exit ; } } add_action ( 'template_redirect' , 'redirect_non_logged_in_users' ) ;

In the above function, it is assumed that the login page has an identifier «10».  The function for the login page will then be similar to the code below.

 function wpdocs_log_me_shortcode_fn() {
ob_start(); 
if(!empty($this->custom_id('d'))) {
$url = get_permalink($this->custom_id('d'))."?clear=".uniqid(); 
} else {
$url = get_permalink( get_the_ID() )."?clear=".uniqid(); 
}
$args = array(
'echo' => true,
'redirect' => $url,
'remember' => true,
'value_remember' => true,
);

wp_login_form($args);
return ob_get_clean();
}

add_shortcode( 'wpdocs_log_me', 'wpdocs_log_me_shortcode_fn');

Finally, you can embed the shortcode in the WordPress editor to display the form.

Use a plugin to turn WordPress into an intranet

How to turn WordPress into an intranet? Two different approaches

How to turn WordPress into an intranet? Two different approaches!

We offer our WordPress extension to create an intranet from your WordPress website. In addition to the tools described above, we have included features that could make your life easier.

How does it work?

The idea behind our extension, available on our website, is to allow you to easily create a secure WordPress-based intranet. Here are the steps to follow:

  • Install the extension on your website
  • Do some basic setup (selection of account creation and login page)
  • Do not opt for the login page if your website does not allow the connection
  • Select the control panel page (if you want your users to have a dedicated panel).
  • Once you are done with the configuration, users will be automatically returned to the connection (if they are not connected).

Other alternatives to turn WordPress into an intranet  (with a plugin)

In general, to turn a WordPress site into an intranet, you should limit access to your site to authorized users only. Here are the steps to achieve this:

Install an access restriction plugin

There are several WordPress plugins that allow you to restrict access to your site. Among the most popular are “Restricted Site Access” and “WP Private Content Plus” . So, install one of these plugins from your WordPress dashboard by going to Plugins > Add.

Configure the access restriction plugin

After installing and enabling the plugin, you must configure it to limit access to your site.

For “Restricted Site Access”:

  • Go to Settings > Reading.
  • Scroll down to the “Site Access” section.
  • Choose “Restrict site access to logged-in visitors” and save the changes.

For “WP Private Content Plus”:

  • Go to Settings > WP Private Content Plus.
  • Configure access restrictions by selecting which parts of the site to protect.
  • Save changes.

Create user accounts

To allow your employees or members of your organization to access the intranet, you must create user accounts for them. To achieve this, go to Users > Add and fill in the required information for each user. Furthermore, be sure to set the appropriate role for each user (administrator, editor, author, contributor, or subscriber) based on the desired permissions.

Install a secure connection plugin (optional)

To increase the security of your intranet, you can install a secure login plugin, such as “Two Factor Authentication” or “Google Authenticator – Two Factor Authentication (2FA)” . This will add an extra layer of security by requiring two-factor authentication to log into the site.

Inform your users

Share the login information with your users (credentials and passwords) and let them know your intranet URL. They will need to log in with this information to access the site.

After following these steps, your WordPress site should be transformed into an intranet and accessible only to authorized users.