{"id":22606652,"url":"https://github.com/benjaminmedia/wp-wa-oauth","last_synced_at":"2026-04-28T11:33:54.281Z","repository":{"id":62493178,"uuid":"58029213","full_name":"BenjaminMedia/wp-wa-oauth","owner":"BenjaminMedia","description":"The wordpress plugin for integrating with the Whitealbum Oauth user api","archived":false,"fork":false,"pushed_at":"2020-02-27T11:49:02.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-26T14:54:36.502Z","etag":null,"topics":["wordpress-plugin"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BenjaminMedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-04T06:44:30.000Z","updated_at":"2020-02-27T10:33:17.000Z","dependencies_parsed_at":"2022-11-02T09:45:36.077Z","dependency_job_id":null,"html_url":"https://github.com/BenjaminMedia/wp-wa-oauth","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenjaminMedia%2Fwp-wa-oauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenjaminMedia%2Fwp-wa-oauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenjaminMedia%2Fwp-wa-oauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenjaminMedia%2Fwp-wa-oauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenjaminMedia","download_url":"https://codeload.github.com/BenjaminMedia/wp-wa-oauth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246106689,"owners_count":20724401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wordpress-plugin"],"created_at":"2024-12-08T14:14:27.128Z","updated_at":"2026-04-28T11:33:54.239Z","avatar_url":"https://github.com/BenjaminMedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bonnier Publications - WordPress WhiteAlbum OAuth plugin\n\nThis plugin enables your WordPress site to integrate with the WA user base.\nIt does it by integrating with the WA OAuth API, and giving you a set of\napi functions that you may call in your theme to conditionally lock content from\nunauthorized users.\n\n### Requirements\n\n- WordPress 4.4 or higher\n- WP REST API must be installed and activated version 2.0 or higher http://v2.wp-api.org/\n- Language support (Optional) Polylang plugin must installed and activated version 1.8.4 or higher\n- PHP 5.6 or higher\n\n### Installation/Configuration\n\nInstall through composer:\n\n``` bash\ncomposer require benjaminmedia/wp-wa-oauth\n```\n\nDownload lastest release from: https://github.com/BenjaminMedia/wp-wa-oauth/releases\nAnd unzip and place in your /wp-content/plugins directory.\n\n#### Getting credentials and Configuration\n\nOnce you have installed and activated the plugin then make sure that you have a set of api credentials.\nIf you do not have a set of credentials then you should contact Bonnier to get them.\nYou need to have a set of credentials for each domain on your site.\nBefore credentials can be generated you must inform Bonnier of the redirect URI that should work with the credentials.\nThis must be in the following format http://|https://[your-domain].[your-country]/wp-json/bp-wa-oauth/v1/oauth/login\n\nExample: http://digitalfoto.dk/wp-json/bp-wa-oauth/v1/oauth/login\n\nOther than the redirect URI you should also tell them which WA userbase you want to\nauthenticate against ie: http://woman.dk or another WA site.\n\nOnce you have your credentials log in to your WP admin panel and go to the menu\nsettings-\u003eWp Wa Oauth: here you must enter each set of credentials you recieved.\n\nHere you also have the option to Globally enable or disable the login for each domain.\nFurthermore you may also select a Globally required user role level.\n\nIf you have multiple languages versions of the site, make sure that you use the Polylang plugin.\n\nIf you wish specific pages to be unlocked or require another user role than the Globally set.\nThen you may visit the the edit page for each page/post and here you will find a meta\nbox called: 'WA OAuth locked content'. Any setting you make here will override\nthe Global settings you have set.\n\n#### Creating local users\n\nAs of version 1.1.0 and up the plugin now supports creating local users.\nThis means that you from the plugin settings page can toggle wether you\nwant the plugin to create WordPress users after they have logged in.\n\nIf you enable this feature you may also choose an option whether the WordPress\nuser should be automatically logged in to WordPress upon authenticating with WA.\n\nUsers will be given custom roles created from the roles that WA delivers: currently\nthis amounts to two roles ```users``` and ```subscribers```. To avoid conflicts\nwith existing WordPress roles the role names will be prefixed with ```bp_wa_```\nmeaning the final role names will be ```bp_wa_users``` and ```bp_wa_subscribers```.\n\nBoth roles will be given only the read access this, will allow users to edit/view their profile and nothing in WordPress and nothing else.\n\nAs of version 1.2.2 the plugin now hijacks already existing users that have the same email address\nas the logged in user from WA. The plugin will update the local user fields with the fields from the \nWA user.\n\n###### Customizing role capabilities:\nYou may override the default capabilities of the roles created you should add\nthe following filters to a plugin or your functions.php file.\n\n``` php\n// To override the default capabilities you should implement a filter like so\n\nadd_filter('bp_wa_users_capabilities', function($default) {\n\treturn array_merge($default, ['edit_posts' =\u003e false]);\n});\n\n// you can either extend the default capabilities by doing an array merge or,\n// you can override the capabilities completely by returning a new array like so\n\nadd_filter('bp_wa_subscribers_capabilities', function($default) {\n\treturn ['edit_posts' =\u003e true];\n});\n\n// note the filter follows a [role_name].[_capabilities] format\n\n```\n\n###### Hooking into the update of local user\n\nAs of version 1.2.0 and up of the plugin you may now hook into the update call of the local user.\nThis is done by adding a WordPress filter using the add_filter method, an example of this can be seen below:\n\n``` php\nadd_filter('bp_wa_oauth_on_user_update', function($users){\n\n\t$localUser = $users['wp']; // Local user object and Instance of the WP_User class\n\t$waUser = $users['wa']; // WhiteAlbum user object an instance of stdClass\n\n\t// Set the user_url property to the profile_image url\n\t$localUser-\u003euser_url = $waUser-\u003eprofile_image-\u003eurl;\n\n\t// You can also save custom_user meta\n\tupdate_user_meta($localUser-\u003eID, 'user_birth_date', $waUser-\u003ebirthdate);\n\n\t// it is important to remember to return the $localUser variable otherwise the changes made will not be saved.\n\treturn $localUser;\n\n});\n```\n\nHere is an example of the data that is returned by the Wa login service:\n\n``` javascript\n{\n\tid: 621905,\n\turl: \"http://woman.dk/users/test-account\",\n\tpath: \"/users/test-account\",\n\tusername: \"test-account\",\n\tfirst_name: \"Test\",\n\tlast_name: \"Account\",\n\tgender: \"male\",\n\tbirthdate: \"1925-06-12\",\n\taddress: \"\",\n\tzip: \"\",\n\tcity: \"\",\n\temail: \"aa@attmatr.com\",\n\troles: [\n\t\t\"users\"\n\t],\n\tbanned: false,\n\tunread_message_count: 0,\n\tprofile_image: {\n\t\tid: 1291263,\n\t\turl: \"http://bonnier.imgix.net/ladygaga-z6VF3a4XTgSQEraVN-qmRQ.jpg\",\n\t\tcopyright: null,\n\t\ttitle: null,\n\t\tdescription: null,\n\t\tuuid: \"ladygaga-z6VF3a4XTgSQEraVN-qmRQ.jpg\",\n\t\tcrops: [ ],\n\t\talt_text: null,\n\t\twidth: 400,\n\t\theight: 300\n\t},\n\tcover_image: null\n}\n\n```\n\n\n#### User update callbacks\n\nIf you have the create local users option enabled, then what might happen is\nthat the user will update their profile on the Main WhiteAlbum site. This,\ncould potentially mean that the local user info that your have in your application\ncan come out of sync. In order to counter this, WhiteAlbum has a callback feature,\nwhich means they can call your application each time there is a change to a user\nthat has been logged in to your application.\n\nThe Plugin automatically setups the callback route and will also handle the update\nof the user information itself, but before WhiteAlbum can call your app.\nThey need to be informed of your callback url. The callback uri is generated from the following format:\nhttp://|https://[your-domain].[your-country]/wp-json/bp-wa-oauth/v1/oauth/callback\n\nExample url: http://test.komputer.dk/wp-json/bp-wa-oauth/v1/oauth/callback\n\nYour should give this url to Bonnier when requesting the credentials, then we\nwill setup the callbacks.\n\nNote: the callback can only work so long as your user has been logged into the application for the last 24 hours. Otherwise the local user information,\nwill not get updated, until the next time they login to your application.\n\n### Usage Example:\n\nThe following code snippet shows an Example in php that may be used in your theme template files.\n\n``` php\n\n\u003c!-- \t\n\tFirst we get an instance of the bp-wa-oauth plugin by calling bp_wa_oauth(),\n\tonce we have an instance we can call the is_authenticated() function.\n\tThis function checks if the user is logged in,\n\tand if they have access to the current page/post.\n\tYou may pass an optional $postId variable to the function,\n\tif you wish to check against a specific page/post.\n--\u003e\n\n\u003c?php if( bp_wa_oauth()-\u003eis_authenticated() ) { ?\u003e\n\n\t\u003c!-- \t\n\t\tIf we are authenticated;\n\t\tthen we can get the current user info by calling: get_user()\n\t\tget_user() returns either a WP_User object or a stdClass if the create\n\t\tlocal user option is disabled.\n\t--\u003e\n\n\t\t\u003c?php echo bp_wa_oauth()-\u003eget_user()-\u003efirst_name; ?\u003e\n\n\t\t\u003c!-- \t\n\t\t\tYou can add logout buttons to trigger a logout, note this will not destroy\n\t\t\tyour WhiteAlbum session. It will only log you out of the current site.\n\t\t--\u003e\n\t\t\u003cbutton class=\"bp-wa-oauth-logout\"\u003elogin and return here\u003c/button\u003e\n\t\t\u003cbutton class=\"bp-wa-oauth-logout\" data-bp-wa-oauth-redirect=\"/some/url\" \u003elogin and redirect to specific url\u003c/button\u003e\n\n\t\t\u003c!-- \t\n\t\t\tIf we are not authenticated;\n\t\t\tthen we can check wether to display the login buttons or not,\n\t\t\tby checking if the current page is locked.\n\t\t\tThis i done by calling the is_locked function, like the is_authenticated()\n\t\t\tthe function will attempt to check the current page/post, but also accepts\n\t\t\tan optional parameter $postId if you wish to check against a specific page/post.\n\t\t--\u003e\n\n\u003c?php } elseif( bp_wa_oauth()-\u003eis_locked() ) { ?\u003e\n\n\t\t\u003c!-- \t\n\t\t\tOn clicking this button the user will be redirected to login screen;\n\t\t\tand returned to the same page on login completion\n\t\t--\u003e\n\t\t\u003cbutton class=\"bp-wa-oauth-login\" \u003elogin current page\u003c/button\u003e\n\n\t\t\u003c!-- \t\n\t\t\tOn clicking this button the user will be redirected to login screen;\n\t\t\tand returned to the url provided in the attr: 'data-bp-wa-oauth-redirect'\n\t\t--\u003e\n\t\t\u003cbutton class=\"bp-wa-oauth-login\" data-bp-wa-oauth-redirect=\"/test/tasker/akvis/tag-ny-test-dk-artikel-test-om-den-kommer\"\u003elogin and redirect to specific url\u003c/button\u003e\n\n\t\t\u003c!-- \t\n\t\t\tNotice how each button has a class \"bp-wa-oauth-login\",\n\t\t\tthis class is what triggers the login JavaScript,\n\t\t\tany element that has this class attached will be clickable;\n\t\t\tand will once clicked, trigger the login flow.\n\t\t--\u003e\n\n\u003c?php } ?\u003e\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminmedia%2Fwp-wa-oauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjaminmedia%2Fwp-wa-oauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminmedia%2Fwp-wa-oauth/lists"}