I ran into the exact same problem, and it’s pretty much a dealbreaker if it can’t be fixed. So I played around with the code and managed to put together a fix. (I haven’t tried the alternative plugin mentioned above–it may be better, but regardless this is a fix for anyone that wants to keep using the CYC plugin!)
Nothing elegant, but prevents users seeing the admin screen!
This involves editing the following two files:
- /wp-admin/user-edit.php — CORE WordPress file
- /wp-content/plugins/customize-your-community/cyc.php — Main Plugin File
As you should always do, be sure to make a backup to these files before going in and editing them!
In /wp-admin/user-edit.php, find the following (~line 143):
if ( !is_wp_error( $errors ) ) {
$redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
wp_redirect($redirect);
exit;
}
and change it to (adding an elseif statment):
if ( !is_wp_error( $errors ) ) {
$redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
wp_redirect($redirect);
exit;
} elseif ($is_profile_page) {
$redirect = "profile.php?" . "errors=" . urlencode(implode('||',$errors->get_error_messages()));
wp_redirect($redirect);
exit;
}
What this does it redirects back to the profile.php page (which will be the non-admin styled one), and sends a get variable with the output text of the errors. It’s sent as a “piped” array.
Second, open up /wp-content/plugins/customize-your-community/cyc.php, and find the following (~line 275):
if ($_GET['updated'] == true) {
echo '<p class="message">Your profile has been updated.</p>';
}
and change it to (again adding an elseif statment):
if ($_GET['updated'] == true) {
echo '<p class="message">Your profile has been updated.</p>';
} elseif ($_GET['errors'] != "") {
$error_messages = explode("||", $_GET['errors']);
echo '<p class="message">';
foreach ($error_messages as $the_msg) {
echo "$the_msg<br />";
}
echo '</p>';
}
This looks for the errors GET variable and if found, prints out each error message. This code can be changed to display the errors however you like, for example in a red box, etc.
This should solve the problem. If anyone tries this out let me know if it works for you!
An important note: Since you’ve changed a core WordPress file and also the plugin code, you’ll have to be careful when upgrading both the WordPress core and the plugin. You either will have to upgrade manually, or make the above changes again after doing an automatic upgrade.
That should be it! Hopefully a real fix will make it into a future CYC version…
Matt