PHP code example of benjaminmedia / wp-wa-oauth

1. Go to this page and download the library: Download benjaminmedia/wp-wa-oauth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

benjaminmedia / wp-wa-oauth example snippets

 php
// To override the default capabilities you should implement a filter like so

add_filter('bp_wa_users_capabilities', function($default) {
	return array_merge($default, ['edit_posts' => false]);
});

// you can either extend the default capabilities by doing an array merge or,
// you can override the capabilities completely by returning a new array like so

add_filter('bp_wa_subscribers_capabilities', function($default) {
	return ['edit_posts' => true];
});

// note the filter follows a [role_name].[_capabilities] format

 php
add_filter('bp_wa_oauth_on_user_update', function($users){

	$localUser = $users['wp']; // Local user object and Instance of the WP_User class
	$waUser = $users['wa']; // WhiteAlbum user object an instance of stdClass

	// Set the user_url property to the profile_image url
	$localUser->user_url = $waUser->profile_image->url;

	// You can also save custom_user meta
	update_user_meta($localUser->ID, 'user_birth_date', $waUser->birthdate);

	// it is important to remember to return the $localUser variable otherwise the changes made will not be saved.
	return $localUser;

});