Site logo

Archived topic

Wordpress Default User Role

5 replies · Started by chris on December 24, 2020

Viewing posts 1–6 of 6

Hi,

I have added a function to snippets, to hopefully change woomcerce's defualt user role. Users when loggd in cant submit listings, they have to be an "Author" and woomcerce is by default giving the role "customer"

This is the snippet i have added to the site, and still nothing.

function my_new_customer_data($new_customer_data){
$new_customer_data['role'] = 'Author';
return $new_customer_data;
}
add_filter( 'woocommerce_new_customer_data', 'my_new_customer_data');

Any ideas?

Hi there,

try:

add_filter('woocommerce_new_customer_data', 'woo_assign_default_role', 10, 1);
function woo_assign_default_role($args) {
  $args['role'] = 'author';
  return $args;
}

Hi, still not working. New users being registered as customer still.

Hi there,

This is probably something you should ask WooCommerce support, as it isn't related to the theme functionality.

After a quick look, the function that David provided looks like it should work. WooCommerce support should be able to tell you why it wouldn't work in your case.

Fired them a message. Could it be the fact im running the code through a plugin? if i was to add the code to the child themes functions.php would the code be any different? thanks

It shouldn't really matter how that code is added. You can of course try testing that by adding it to a Child Themes Functions.php.

This archived topic is closed to new replies.