Hiding div based on user role

Basically, just check inside the action if an array of the current user’s roles contains the wholesale role. function content_below_checkout_button() { if ( in_array( ‘wholesale’, wp_get_current_user()->roles ) ) { echo ‘<div style=”text-align: center”><img style=”margin-top:20px; display:inline-block;” src=”/uploads/2020/07/image.png’.$photo->name.'”/></div>’; } } add_action( ‘woocommerce_review_order_after_submit’, ‘content_below_checkout_button’ ); I’m not sure what’s going on with the rest of your code, but … Read more

How to limit the number of forgot password reset attempts in WordPress?

You need put the attempts on user meta, then do check every time user hit reset passwords. add_action( ‘password_reset’, ‘my_password_reset’, 10, 2 ); function my_password_reset( $user, $new_pass ) { $limit=5;// Set the limit here $attempts=(int) get_user_meta($user->ID,”reset_attempts”,true); if($attempts>$limit){ //Do something in here, example redirect to warning page. wp_redirect( “/warning” ); exit; } update_user_meta($user->ID,”reset_attempts”,$attempts++); }

How to pass aa JS variable to PHP?

Step 1: Run wp_localize_script, add below function in function.php add_action( ‘wp_enqueue_scripts’, ‘jsto_php_enqueue_scripts’, 5 ); public function jsto_php_enqueue_scripts() { wp_register_script( ‘file_handle’, plugin_dir_url( __FILE__ ) . ‘js/js-file-name.js’, array( ‘jquery’ ), ‘0.0.1’, false ); wp_enqueue_script(‘file_handle’); // Set Nonce Values so that the ajax calls are secure $add_something_nonce = wp_create_nonce( “add_something” ); $ajax_url = admin_url( ‘admin-ajax.php’ ); $user_id = … Read more