how to use apply filter for Class?

To add a filter of a class’s method you must use an array in the callback like this: add_filter( ‘woocommerce_credit_card_form_fields’, array( $this, ‘ggowl_auth_creditform’ ), 10, 1 );. Of course that method must be public and either static, or the object must be instantiated.

Translate are not working for standard admin

The only instance of “Count” I can see in the default domain’s admin file has a context value of “Number/count of items”. So your code should be: add_action( ‘admin_init’, ‘action_admin_init’ ); function action_admin_init() { _ex( ‘Count’, ‘Number/count of items’ ); } Ref: _ex.

add_action doesn’t work for my function

HI please check below code. add_action( ‘user_register’, ‘fill_identity’, 10, 1 ); function fill_identity($user_id){ $current_user = get_userdata($user_id); $mail_user = $current_user->user_email; $mail_user = substr($mail_user,0,-14); $mail_user = explode(“.”, $mail_user); $prenom = $mail_user[0] = ucfirst($mail_user[0]); $nom = $mail_user[1] = ucfirst($mail_user[1]); var_dump($mail_user); wp_update_user(array( ‘ID’ => $current_user->ID, ‘first_name’ => $prenom, ‘last_name’ => $nom, )); }

Best hook for when a user session ends?

There is an auth_cookie_expired hook, but that’s only going to fire if the user visits the site with an expired cookie. Sessions don’t “end” in the way you might be thinking. When users log in they get a session token with an expiration. When that expiration time passes, the token is no longer valid, but … Read more

How to show only specific category post by user role without plugin and restrict all other cats

If you’re using global loop for displaying the posts, then you can easily modify which posts are shown using pre_get_posts action. function restrict_categories_for_user( $query ) { if ( ! is_admin() && $query->is_main_query() && get_current_user_id() ) { $user = wp_get_current_user(); if ( in_array( ‘viewer_a’, (array) $user->roles ) ) { // The user has the “viewer_a” role … Read more

Use action, filter, or hook to append HTML to WordPress plugin function

The do_action calls allow you to add an add_action that will run at that point int he code. Based on the code you provided, you can add a new row using the mpp_user_profile_form action, like: add_action( ‘mpp_user_profile_form’, function( $user_id ) { ?> <tr> <p class=”appended-text”> <strong>Note: optimum image size is 200 pixels wide by 200 … Read more

add_action with associative array

You passed the action an associative array, so your hooked function will recieve an associative array. It’s a little clearer if we retype it like this: $associative_array = array( ‘product_id’ => $product_id , ‘outbiddeduser_id’ => $outbiddeduser, ‘log_id’ => $log_id ); do_action( ‘woocommerce_simple_auctions_outbid’, $associative_array ); Thus: add_action(‘woocommerce_simple_auctions_outbid’, ‘test’, 10, 1); function test( $associative_array ) { It … Read more