Turnkey Plugins \ Social Login for WordPress

The Social Login Plugin for WordPress is a professional though free plugin that allows your visitors to comment, login and register with social networks like Twitter, Facebook, LinkedIn, Hyves, Google and Yahoo. An easy and straightforward plugin to increase your user engagement. Download Social Login for WordPress

  1. Installation
  2. Setup
  3. Actions, Hooks & Filters
  4. Shortcodes
  5. Troubleshooting

1. How to install Social Login for WordPress?

1.1. Automatic Installation:

  1. Login to your WordPress blog as administrator,
  2. Click on Plugins in the left navigation panel,
  3. Click on Add New at the top of the page,
  4. Enter oneall social login in the search box and click on Search Plugins,
  5. Look for Social Login and click on Install Plugin.

1.2. Manual Installation:

  1. Download the latest version of the Social Login Plugin here: WordPress Social Login,
  2. Upload the plugin folder to the /wp-content/plugins/ directory of your WordPress website,
  3. Login to your WordPress blog as administrator,
  4. Click on Plugins in the left navigation panel,
  5. Activate the plugin.

2. How to setup Social Login for WordPress?

After having installed Social Login on your WordPress blog you have to enter your API credentials and you must setup the social networks that you would like to use.

2.1. How to obtain your API Credentials?

  1. Login to your existing OneAll account or alternatively create a new account.
  2. Click on Site Configuration in the top navigation bar,
  3. Click on the name of your site (If you do not have a site yet, please create a new site first),
  4. Copy & paste the values at API Access Credentials into the Social Login plugin settings in your WordPress account.

2.2. How to setup the Social Networks?

Many social networks require that the webmasters register their websites before being able to use more advanced features. To be able to use some of the social networks (i.e. Facebook & Twitter), you will therefore have to register your blog.

This process is straightforward and takes only a couple of minutes. It has to be done only once for each provider and we will guide you through this process. To setup your providers, please login to your OneAll account, and on the dashboard click on Social Networks in the QuickLinks of your Site.

3. Actions, Hooks & Filters

The codes in the following examples have to be added to the end of the functions.php file of your WordPress theme. By doing so your changes will not be overwritten when you install a new version of Social Login. You can find this file in your WordPress administration area under Appearance \ Editor \ Theme Functions (functions.php)

3.1 How to store additional data retrieved from a social network profile?

The standard WordPress database does not have the required tables/fields to store the complete user profile retrieved from the social networks. To store the full user profile you must extend the structure of your database and then use an action like this:

//Handle data retrieved from a social network profile
function oa_social_login_store_extended_data ($user_data, $identity)
	// $user_data is an object that represents the newly added user
	// The format is similar to the data returned by $user_data = get_userdata ($user_id);

	// $identity is an object that contains the full social network profile
	//Example to store the gender
	update_user_meta ($user_data->id, 'gender', $identity->gender);

//This action is called whenever Social Login adds a new user
add_action ('oa_social_login_action_after_user_insert', 'oa_social_login_store_extended_data', 10, 2);

3.2 How to store additional data in BuddyPress Xprofile fields?

//Store data retrieved from a social network profile in BuddyPress Xprofile fields
function oa_social_login_store_xprofile ($user_data, $identity)
  // $user_data is an object that represents the newly added user
  // The format is similar to the data returned by $user_data = get_userdata ($user_id);
  // $identity is an object that contains the full social network profile
	//The following line is required to initialise the BuddyPress table names
  //Example to store the firstname/lastname
	xprofile_set_field_data ('First Name', $user_data->ID, $identity->name->givenName);
	xprofile_set_field_data ('Last Name', $user_data->ID, $identity->name->familyName);
add_action( 'oa_social_login_action_after_user_insert', 'oa_social_login_store_xprofile', 10, 2);

3.3 How to allow only logins from a specific email address?

//Verify the email address of a new user
function oa_social_login_restrict_new_user_email ($user_email)
	//Only users with social network accounts having an email address ending in @gmail.com may register
	if ( ! preg_match ('/@gmail\.com$/i', trim ($user_email)))
		trigger_error ('This email address may not be used to register', E_USER_ERROR);
	return $user_email;

//This filter is applied to the email addresses of new users
add_filter('oa_social_login_filter_new_user_email', 'oa_social_login_restrict_new_user_email');

3.4 How to use the email address as user login?

To make sure that you receive the email addresses from your users you should also enable the following option in the Social Login settings in your WordPress admin area: If the user's social network profile has no email address, should we ask the user to enter it manually?

//Use the email address for user_login
function oa_social_login_set_email_as_user_login ($user_fields)
	if ( ! empty ($user_fields['user_email']))
		if ( ! username_exists ($user_fields['user_email']))
			$user_fields['user_login'] = $user_fields['user_email'];

	return $user_fields;

// This filter is applied to new users
add_filter('oa_social_login_filter_new_user_fields', 'oa_social_login_set_email_as_user_login');

3.5 How to set a custom role for new Social Login users?

//Set a custom role for a new user
function oa_social_login_set_new_user_role ($user_role)
	//This is an example for a custom setting with one role
	$user_role = 'author';
	//This is an example for a custom setting with two roles
	$user_role = 'author editor';

	//The new user will be created with this role
	return $user_role;

//This filter is applied to the roles of new users
add_filter('oa_social_login_filter_new_user_role', 'oa_social_login_set_new_user_role');

3.6 How can I use my own CSS to customize Social Login?

To customize Social Login you first of all have to create a new CSS file on your server and then you must use the following filter to include the CSS file in the plugin. Please note that custom icons are only available starting with our Basic Plan.

//Use a custom CSS file with Social Login
function oa_social_login_set_custom_css($css_theme_uri)
	//Replace the URL by an URL to your own CSS file
	$css_theme_uri = 'http://public.oneallcdn.com/css/api/socialize/themes/buildin/connect/large-v1.css';
	return $css_theme_uri;
add_filter('oa_social_login_default_css', 'oa_social_login_set_custom_css');
add_filter('oa_social_login_widget_css', 'oa_social_login_set_custom_css');
add_filter('oa_social_login_link_css', 'oa_social_login_set_custom_css');

4. Shortcodes

Since Version 2.5 WordPress supports so called Shortcodes. These codes can be used to manually embed Social Login into your blog posts. The following shortcodes are included with Social Login:

4.1. Social Login

This shortcode will display Social Login and allow users to login with their social network account. Please note that Social Login is only displayed for users that are not logged in.


Alternatively you can also use the following PHP code which will produce the same result:

<?php do_action('oa_social_login'); ?>

4.2. Social Link

The Social Login plugin for WordPress also includes our Social Link service that allows users to manually link/unlink social network accounts to/from their WordPress account.

The following shortcode can be used to embed Social Link. Please note that Social Link is only displayed for users that are already logged in. Social Link will not be displayed for guests.


Alternatively you can also use the following PHP code which will produce the same result:

<?php do_action('oa_social_link'); ?>

4.3 Conditionally display content

Social Login also includes shortcodes to conditionally display content for users that have/have not logged in with a social network account. The content between the shortcode will only be displayed if the defined condition is met.

	[oa_social_login_test is_social_login_user="true"]
		This content is displayed only if the user IS logged in AND has used Social Login to login.

	[oa_social_login_test is_social_login_user="false"]
		This content is displayed only if the user IS logged in AND has NOT used Social Login to login.

5. Troubleshooting

5.1. The Social Login buttons are not being displayed in my comments area!

The plugin uses existing WordPress hooks to seamlessly integrate into your blog. If your theme does not support these hooks, the plugin will not be displayed correctly. You can add the Social Login features manually by inserting the following code into your template:

<?php do_action('oa_social_login'); ?>

This code has be added at the location where Social Login should be displayed, i.e. above the comments form.

  1. Login to your blog as administrator,
  2. Click on Appearance and then Editor,
  3. Click on Comments (comments.php) in the file list to your right,
  4. Look for <h3><?php comment_form_title( 'Leave us your thoughts', 'Leave a Reply to %s' ); ?></h3>
  5. Add the code <?php do_action('oa_social_login'); ?> below.

Your theme might look slightly different. Try adding <?php do_action('oa_social_login'); ?> to another place in the code and check if the Social Login options are displayed. Please note that the buttons will not be displayed while you are logged in. If you are not sure where to add the tag, feel free to contact us, we will help you set it up.

5.2. I get an error 403 when logging in with a social network!

If you have installed the Bad Behavior plugin you might encounter the following error:

Error 403

We're sorry, but we could not fulfill your request for /?oa_social_login_source=widget on this server.
You do not have permission to access this server. Data may not be posted from offsite forms.
Your technical support key is: 4466-1157-cd36-1abb

You can use this key to fix this problem yourself.
If you are unable to fix the problem yourself, please contact XXX at gmail.com and be sure to provide the technical support key shown above.

To fix this issue you must open the Bad Behavior settings in your WordPress administration area and Enable Offsite Forms. More information about this restriction is available in the Bad Behavior documentation.

5.3. The API Communication does not seem to work correctly!

Please make sure that your firewall does not block outbound requests on both ports 80 and 443. One of these ports must allow outgoing requests (from your server to ours) so that the plugin can establish a communication with our API.

If you have access to the console of your server you can test if outbound requests are allowed by using this command: telnet ping.api.oneall.com 443. If the port is open then you should obtain a result like this:

	~$ telnet ping.api.oneall.com 443
	Connected to ping.api.oneall.com.
	Escape character is '^]'.

5.4. Social Login does not work with special (russian, cyrillic, arabic) characters!

Per default WordPress does not allow to use special characters in usernames. Non-latin characters are silently filtered out and your users cannot create accounts that contain such characters. To enable accounts with special characters you first of all have to install this plugin: WordPress Special Characters in Usernames

If users with longer usernames can no longer register after having installed that plugin then you might have to increase the length of the column user_nicename in the table wp_users in your database.

	ALTER TABLE `wp_users` CHANGE `user_nicename` `user_nicename` VARCHAR(255) NOT NULL DEFAULT ''