hide woo commerce dashboard status and reports from woo commerce from specific users but display to other users

For the dashboard case. if ( !current_user_can(‘manage_options’) ) { function remove_dashboard_widgets() { // remove WooCommerce Dashboard Status remove_meta_box( ‘woocommerce_dashboard_status’, ‘dashboard’, ‘normal’); } add_action(‘wp_user_dashboard_setup’, ‘remove_dashboard_widgets’, 20); add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’, 20); }

How to expire guest users after 1.5 hours logged in?

In your single.php template file: <?php if (has_post()) { the_post(); $user = wp_get_current_user(); $hasPermission = in_array(‘subscriber’, $user->roles); // or maybe instead of a role, you can check for your custom permission: // $hasPermission = current_user_can(‘view_access_codes’); $postTime = get_post_time(‘U’, true); $timeThreshold = time() – 60 * 60 * 1.5; $hasTimePassed = $postTime < $timeThreshold; if (!$hasPermission … Read more

How to get current user ID in array meta_value?

WP_User_Query is a user search. This sentence… But I need to echo only those users name whose meta_key= something but meta _value is equal to current user ID. … suggests that that is not really what you want. I think you can accomplish this with: $current_user = wp_get_current_user(); $meta = get_user_meta($current_user->ID, ‘Something’, true); if (!empty($meta)) … Read more

how to show logged in members username in wordpress content

It looks like $current_user->user_firstname contains some tag content. I would replace that line with: <h5>Hi <?php echo esc_html($current_user->user_firstname); ?></h5> or <h5>Hi <?php echo strip_tags($current_user->user_firstname); ?></h5> One of those (or either) may solve your problem outright.

How-To: Get meta data from the users last order in woocommerce

First thing is to grab the last order ID, you can do it with a simple WP_Query $args = array(‘post_type’=>’product’, ‘posts_per_page’=>1, ‘orderby’=>’ID’, ‘orderby’=>’DESC’); $query= WP_Query($args); As this will only give only one result, you don’t need to loop the result, $order_id= $query->posts[0]->ID; Now, you can reach the order data, $order = WC_Order($order_id); You can use … Read more

Limit user access to installing/configuring a plugin?

WP doesn’t have a built-in way to restrict permissions this granularly. You can either install plugins, or not. For settings, it depends on where the plugin surfaces its settings. For example, if the settings are under the “Settings” menu, then by default only users with role “administrator” will be able to access and adjust them. … Read more

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