WooCommerce get_author_posts_url() – Author URL redirecting to shop base

I found! https://wordpress.org/support/topic/how-to-add-author-page-to-custom-user-role/#post-8807168 So in WooCommerce, this is achieved by the following code in wp-content/plugins/woocommerce/includes/wc-user-functions.php: /** * Disable author archives for customers. * * @since 2.5.0 */ function wc_disable_author_archives_for_customers() { global $wp_query, $author; if ( is_author() ) { $user = get_user_by( ‘id’, $author ); if ( isset( $user->roles[0] ) && ‘customer’ === $user->roles[0] ) { … Read more

allowing subscriber role to delete their own posts

The capability required to delete posts is delete_posts. If you want them to be able to delete their own published posts, the capability is delete_published_posts. The capability required to view the administration panel is read. Subscribers have this capability natively, so unless you have removed it, subscribers can access the backend. I would write a … Read more

WooCommerce Admin order – Only run action if user is loaded

One way of doing this is check with the get_current_user() and check if return something, if yes, run the code. Like the example below: add_action( ‘woocommerce_admin_order_data_after_order_details’, ‘ccef_order_switch_to’, 99 ); /** * Add a switch to user link on the order details. * * @param object $order The WC Order that we’re working with. */ function … Read more

How to add array [closed]

You don’t need array to do this. The following code will be worked. You have to just add other username also inside if condition with or operation. if (‘plugins.php’ === $pagenow ||’update-core.php’ === $pagenow ) { // wp_safe_redirect( home_url() ); // Now check the current user $user = wp_get_current_user(); if ( $user->user_login == ‘Remo’ || … Read more

Problems using ‘add_role’

You can pass the user’s role directly to wp_insert_user(). First, you can try to add your custom role to the WP_Roles object, then pass the custom role to the user properties: // Add custom roles only once to avoid unnecessary database calls. // It is usually done during plugin activation. register_activation_hook( __FILE__, ‘cyb_add_roles’ ); function … Read more

Allow user edit widgets

The edit_theme_options capability controls access to the widgets page but also to the menus page. You can then remove the menus submenu from appearance for a specific role, and if someone tries to get there by url, redirect it : /** * Remove the “Menus” submenu from Appearance */ function remove_menus() { if (in_array(‘administrator’, wp_get_current_user()->roles)) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)