File Path : \wp-content\plugins\woocommerce\includes\wc-user-functions.php
Function Name: wc_modify_editable_roles
============================================================
Code Before Changes:
function wc_modify_editable_roles( $roles ) {
if ( ! current_user_can( 'administrator' ) ) {
unset( $roles['administrator'] );
}
if ( current_user_can( 'shop_manager' ) ) {
$shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) );
return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) );
}
return $roles;
}
add_filter( 'editable_roles', 'wc_modify_editable_roles' );
===============================================================
Code After Changes:
function wc_modify_editable_roles( $roles ) {
if ( ! current_user_can( 'administrator' ) ) {
unset( $roles['administrator'] );
if ( current_user_can( 'shop_manager' ) ) {
$shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) );
return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) );
}
}
return $roles;
}
add_filter( 'editable_roles', 'wc_modify_editable_roles' );
]]>All previous user roles seem to be unaffected, so I am still a Super Admin and other admins, editors, etc are fine, but any new users or newly assigned users can only be customers on any site, new and old.
I believe that the customer role is automatically created by WooCommerce, but so is the Shop Manager and that isn’t showing up.
Let me know any other details you would like to know. WP Core and plugin files are all up-to-date.
]]>I am having a bot of trouble. When a subscription is paid for, using woocommerce the “subscriber” is automatically moved to the “customer” role.
When the “customer gets directed back to his profile page, it remains blank.
Having tested for reasons as to why he cant view the form. Even though the form is role specified through UM and WC. I noticed that when i chnage his WP role back to subscriber it workd perfectly.
Is there any way to update allow access as “customer role” the certain forms? Or how can I allow these “customers£” access to their profiles?
Regards,
William
https://www.ads-software.com/plugins/ultimate-member/
]]>It doesn’t update the role for the registered user. It just adds None to the role after the registration is complete, but in essence I need the role which was selected to be saved when saving the username and other fields.
Here is what I have so far –
I have a registration form with fields which has radio choices like –
<label>
<input type="radio" name="user_role" id="Role1<?php $template->the_instance(); ?>_r" class="input"
<?php if (isset($_POST['user_role']) && $_POST['user_role'] == 'Role1' ) echo 'checked="checked"'; ?> value="Role1"/>Role1
</label>
<label>
<input type="radio" name="user_role" id="Role2<?php $template->the_instance(); ?>" class="input"
<?php if (isset($_POST['user_role']) && $_POST['user_role'] == 'Role2' ) echo 'checked="checked"'; ?> value="Role2"/>Role2
</label>
This is what I have in another page that will process the incoming data.
The error module works fine, ie. It only shows the error message when I am not checking any role in my registration page.
<?php
function tml_registration_errors( $errors ) {
if ( !isset( $_POST['user_role'] ) )
$errors->add('empty_user_role', '<strong>ERROR</strong>: Please select a role.');
return $errors;
}
add_filter( 'registration_errors', 'tml_registration_errors' );
Saving module below doesn’t take effect and I am having issues. For debugging purpose I have the alert setup but that doesn’t alert show the alert box either, it is just bypassed and “None” is added to the role column in the dashboard view of user list.
function tml_user_register( $user_id ) {
$user = new WP_User( $user_id );
if ($_POST['user_role'] = 'Role1'){
echo "<script>alert('" . $_POST['user_role'] . "');</script>";
$user->remove_role( 'Default Role' );
$user->set_role( 'Role1' );
update_user_meta( $user_id, 'role', $_POST['user_role'] );
unset( $user );
}else{
echo "<script>alert('" . $_POST['user_role'] . "');</script>";
$user->remove_role( 'Default Role' );
$user->add_role( 'Role1' );
$user->set_role( $_POST['user_role'] ) ;
update_user_meta( $user_id, 'role', $_POST['user_role'] );
unset( $user );
}
}
add_action( 'user_register', 'tml_user_register' );
?>
Please help me with this, I am trying for past one or two days but in vain. I am not a hardcore PHP programmer but very much a beginner, any help is really appreciated. Thank you in advance.
]]>Thank you!
Susan
https://www.ads-software.com/plugins/press-permit-core/
]]>Same message appears, when she tries to access her profile.
However, she is able to add / view posts by manually typing in ../wp-admin/edit.php in the url.
[OBSERVATION]. soon after loggin in, all are redirected to …/wp-admin.. section of the dashboard (correct behaviour)
But, the …wp-admin.. assumes that all are “site-admin” and when it encounters a user who is “Not Site Admin”.. the error message shows up.
Is it possible to write a custom page (userdash.php) and have this detect and redirect the user to appropriate url, using “Roles” as the identifying criteria? … may be.. there is a much simpler fix..i just dont know it yet
I just want the user (contributor) to add posts (& submit for review), edit her posts, and possibly edit her profile as well… Nothing out of the way
[OBSERVATION].
https://www.ads-software.com/extend/plugins/wp-roles-at-registration/
]]>