Change WordPress user roles and capabilities › Forums › How to or FAQ › Problem with shortcodes after moving WP to a new server
Tagged: Installation multisite main_blog
- This topic has 18 replies, 2 voices, and was last updated 8 years, 5 months ago by Vladimir.
-
AuthorPosts
-
27/06/2016 at 18:21 #2441kardonParticipant
I am working with the hosting provider on this however it may be something you can provide direction quickly.
All worked fine in my Multisite install. It was converted from one server to another over the weekend and now my pages using the content control shortcode are showing the shortcodes. For example: [user_role_editor roles=”k-comply”] some content that those users should see [/user_role_editor] is actually displayed on the page when we go to it instead of not showing it to us as it used to do.
Any ideas would be appreciated. We have removed the plugin and reinstalled it. The license shows active but not sure where else to go from here myself.
28/06/2016 at 02:08 #2443VladimirKeymasterCheck if ‘Activate [user_role_editor roles=”role1, role2, …”] shortcode’ checkbox at URE’s settings ‘Additional modules’ tab is turned ON at ‘Network Admin’ if URE is network activated or for the site to which this page is belongs.
28/06/2016 at 13:21 #2445kardonParticipantIt was not on. I set it to ON. But, the problem persists.
Hosting tech seems to think this error is related:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
jquery-migrate.min.js:2 JQMIGRATE: Migrate is installed, version 1.4.1https://kardonhq.net/wp-content/plugins/media/style.css?ver=e6fbd43a92cc6bc14580501f0ea9497f Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Because wp-content/plugins/media folder doesn’t exist the error happens.
28/06/2016 at 21:55 #2447kardonParticipantI have discovered the issue is only on subsites, not the main network site. Is there a way I can reset that or check to see if the subsites are set to use the shortcode?
29/06/2016 at 02:50 #2451VladimirKeymasterIs URE network activated or per the single subsites?
29/06/2016 at 04:45 #2452kardonParticipantIt is Network Activated and the box for Activate [user_role_editor roles=”role1, role2, …”] shortcode is checked.
29/06/2016 at 05:59 #2453VladimirKeymasterCould you compare the output from WordPress (adding this code to the functions.php, for example):
global $current_site; echo 'Main site ID: '. $current_site->blog_id;
and from this SQL query:
select blog_id from wp_blogs order by blog_id asc limit 0, 1;
use your own DB prefix instead of a default ‘wp_’ if you changed it.
29/06/2016 at 13:05 #2454kardonParticipantMain site ID: 1
blog_id 1
30/06/2016 at 12:41 #2458kardonParticipantIs there any way to force the sub-sites to see the shortcodes?
30/06/2016 at 12:56 #2459kardonParticipantOK, I found shortcodes.php and made a change to force it ON
class URE_Shortcodes {
private $lib = null;
public function __construct(Ure_Lib_Pro $lib) {
$this->lib = $lib;
$activate_content_for_roles_shortcode = $this->lib->get_option(‘activate_content_for_roles_shortcode’, false);
$activate_content_for_roles_shortcode = true;
if ($activate_content_for_roles_shortcode) {
add_action(‘init’, array($this, ‘add_content_shortcode_for_roles’));
}
}
// end of __construct()I did do an echo on that before and after setting it to test it. When it did the get_option the variable returned was blank.
So, this is the problem. How can I fix the get to the db to return the value of ON. I checked once again and that box is checked on the network settings for URE.
30/06/2016 at 14:14 #2460VladimirKeymasterIf URE is network activated it uses options data from the main blog for all subsites.
Your site new installation differs somehow. Try to debug code related for work with options data to understand what’s going wrong with your setup and enhance the URE’s code.Main blog ID is defined at includes/classes/base-lib.php constructor:
$this->main_blog_id = $this->blog_ids[0][0];
Let’s replace it with this line:
$this->main_blog_id = $this->get_main_site();
and add a new public method to URE_Base_Lib class:
public function get_main_site() { global $current_site; return $current_site->blog_id; } // end of get_main_site()
This way we will relay on WordPress in a question of main site ID definition.
Test shortcodes after this update. Just in case debug data you showed yesterday was not actual somehow and main site ID is not 1.
If it will not help, let’s proceed with debugging of init_options method at includes/classes/ure-lib.php, line #154.
User Role Editor takes its configuration/options data from there. As you can see it switches to the main blog before to get data if it’s network wide activated under WP multisite.
30/06/2016 at 17:45 #2466kardonParticipantOK, here is what I have learned.
I put thIS code in the theme functions.php
echo '</br> Main site ID theme functions.php: '. $current_site->blog_id;
and then also added it to the ure-lib.php.
protected function init_options($options_id) { global $wpdb; if ($this->multisite) { if ( ! function_exists( 'is_plugin_active_for_network' ) ) { // Be sure the function is defined before trying to use it require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } $this->active_for_network = is_plugin_active_for_network(URE_PLUGIN_BASE_NAME); } $current_blog = $wpdb->blogid; if ($this->multisite && $current_blog!=$this->main_blog_id) { if ($this->active_for_network) { // plugin is active for whole network, so get URE options from the main blog switch_to_blog($this->main_blog_id); } } echo '</br> Main site ID ure-lib: '. $current_site->blog_id.' '; $this->options_id = $options_id; $this->options = get_option($options_id); if ($this->multisite && $current_blog!=$this->main_blog_id) { if ($this->active_for_network) { // plugin is active for whole network, so return back to the current blog restore_current_blog(); } }
This is what it returns:
Main site ID ure-lib:
Main site ID theme functions.php: 1I don’t know why it knows the value in one place and not the other. If you give me more direction I will do further analysis, though.
Thanks so very much for all your help with this!!
01/07/2016 at 01:59 #2468VladimirKeymasterYou have to add a line
global $current_site;
inside init_options() functions before check property value of this object. This variable is unavailable in other case.
01/07/2016 at 21:51 #2478kardonParticipantprotected function init_options($options_id) { global $wpdb; if (ç) { if ( ! function_exists( 'is_plugin_active_for_network' ) ) { // Be sure the function is defined before trying to use it require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } $this->active_for_network = is_plugin_active_for_network(URE_PLUGIN_BASE_NAME); } $current_blog = $wpdb->blogid; if ($this->multisite && $current_blog!=$this->main_blog_id) { if ($this->active_for_network) { // plugin is active for whole network, so get URE options from the main blog switch_to_blog($this->main_blog_id); } } $this->options_id = $options_id; $this->options = get_option($options_id); if ($this->multisite && $current_blog!=$this->main_blog_id) { if ($this->active_for_network) { // plugin is active for whole network, so return back to the current blog restore_current_blog(); } } <strong>echo '</br> ure-lib:$this->multisite '. $this->multisite; echo '</br> ure-lib:$current_blog: '. $current_blog; echo '</br> ure-lib:$this->main_blog_id: '. $this->main_blog_id; echo '</br> ure-lib:this->active_for_network: '. $this->active_for_network;</strong> } // end of init_options()
This code that echos the exact variable names used in the function returns this:
ure-lib:$this->multisite 1
ure-lib:$current_blog: 38
ure-lib:$this->main_blog_id:
ure-lib:this->active_for_network: 1I then added the global line you mentioned and the echo of it.
ure-lib:$current_site->blog_id 1
ure-lib:$this->multisite 1
ure-lib:$current_blog: 38
ure-lib:$this->main_blog_id:
ure-lib:this->active_for_network: 1Does this provide any clue to the problem?
02/07/2016 at 02:51 #2481 -
AuthorPosts
- You must be logged in to reply to this topic.