Skip to content

Instantly share code, notes, and snippets.

View nextendweb-laszlo's full-sized avatar

nextendweb-laszlo

View GitHub Profile
<?php
function redirectWhenRoleMatches($user_id, $provider) {
$user = get_userdata($user_id);
$user_roles = $user->roles;
if (in_array('subscriber', $user_roles, true)) {
add_filter($provider->getId() . '_login_redirect_url', function () {
return 'https://example.com/page-for-subscribers';
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form method="post" action="https://****/wp-json/nextend-social-login/v1/google/get_user">
<input type="text" name="access_token" value=""/>
<button type="submit">Submit</button>
@nextendweb-laszlo
nextendweb-laszlo / curl-test.php
Last active June 9, 2020 11:29
NSL REST API - POST with cURL
<?php
$url = 'https://example.com/wp-json/nextend-social-login/v1/facebook/get_user';
$access_token = array(
'access_token' => '{"access_token":"EAAKdOKespJMBAKKanbl7q4vnqvGS6JpJE1IkLIlklxkBtBjIG1u0piAQLby6fwZAj0NGtOSJqY4A6PTfpzWhx77Pci0joIb01RChGO6sMgxShXZBcfnSDBdwTLopyHrtxnCqM7OLvhCCMOaJ2RxFKSAPdqCbhWrZCMxh5w1GIPAZCGxJCKr4jVl43Ig8oCQZD","token_type":"bearer","expires_in":5108158}'
);
$ch = curl_init($url);
$postQuery = http_build_query($access_token);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postQuery);
<?php
function excludeUrlFromFixedRedirect($fixedRedirectUrl, $provider) {
$pageWhereButtonWasClicked = NSL\Persistent\Persistent::get('redirect');
$excluded_url = 'https://example.com/checkout';
if ($pageWhereButtonWasClicked && strpos($pageWhereButtonWasClicked, $excluded_url) !== false) {
return false;
}
return $fixedRedirectUrl;
@nextendweb-laszlo
nextendweb-laszlo / nslAvatarsWithBuddyboss.php
Last active July 13, 2023 12:44
BuddyBoss - Store the avatars coming from Nextend Social Login.
<?php
/*
Plugin Name: NSL Avatars for BuddyBoss
description: This plugin can be used for storing the avatars of Nextend Social Login with the theme BuddyBoss.
Version: 1.1
Author: Laszlo Szalvak
*/
class nslAvatarsWithBuddyboss {