Forked from carlodaniele/kinsta-share-users.php
Created
April 24, 2019 06:56
Revisions
-
carlodaniele revised this gist
Aug 28, 2016 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,7 @@ * @param array $old_roles An array of the user's previous roles. * * @link https://developer.wordpress.org/reference/hooks/set_user_role/ * @link https://codex.wordpress.org/Plugin_API/Action_Reference/set_user_role * */ function ksu_save_role( $user_id, $role ) { -
carlodaniele revised this gist
Aug 28, 2016 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,16 @@ Author URI: http://carlodaniele.it/en/ */ /** * Duplicate {$pref}_capabilities and {$pref}_user_level rows in {$pref}_usermeta table * * @param int $user_id The user ID. * @param string $role The new role. * @param array $old_roles An array of the user's previous roles. * * @link https://developer.wordpress.org/reference/hooks/set_user_role/ * */ function ksu_save_role( $user_id, $role ) { // Site 1 -
carlodaniele created this gist
Aug 28, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ <?php /** * @package Kinsta_Share_Users * @version 1.0 */ /* Plugin Name: Kinsta Share Users Plugin URI: http://wordpress.org/extend/plugins/# Description: This is an example plugin for Kinsta blog readers Author: Carlo Daniele Version: 1.0 Author URI: http://carlodaniele.it/en/ */ function ksu_save_role( $user_id, $role ) { // Site 1 // Change value if needed $prefix_1 = 'first_'; // Site 2 prefix // Change value if needed $prefix_2 = 'second_'; $caps = get_user_meta( $user_id, $prefix_1 . 'capabilities', true ); $level = get_user_meta( $user_id, $prefix_1 . 'user_level', true ); if ( $caps ){ update_user_meta( $user_id, $prefix_2 . 'capabilities', $caps ); } if ( $level ){ update_user_meta( $user_id, $prefix_2 . 'user_level', $level ); } } add_action( 'set_user_role', 'ksu_save_role', 10, 2 );