I have a custom field on user profiles on the admin side.
I would like to be able to check the value of this custom field an display a message in some cases.
I looked at the wordpress documentation, read about the profile_update hook, but it fires after the update.
And besides I wonder how I could display a message.
Thanks for your help.
Ok so I used the following hooks to add the fields
add_action( 'show_user_profile', 'add_custom_user_profile_fields' );
add_action( 'edit_user_profile', 'fb_add_custom_user_profile_fields' );
and to check before update
add_action( 'personal_options_update', 'save_custom_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_custom_user_profile_fields' );
checkout this codex link it useful for you
https://codex.wordpress.org/Plugin_API/Action_Reference/personal_options_update
Related
For woocommerce: is there a hook fired when a woocommerce coupon is created?
I need to add this hook in myTheme/functions.php to fire an action just at a coupon creation.
UPDATE:
I included this code in my functions.php but it doesn't seem to work. It should print "it works" at coupon creation but it doesn't. No error, nothing at all.
function after_new_coupon_created( $coupon_id, $coupon ){
echo "it works";
}
add_action( 'woocommerce_new_coupon', 'after_new_coupon_created', 10, 2 );
As Alon Eitan said in the comment you can use like below.
function after_new_coupon_created( $coupon_id, $coupon ){
// your code here.
}
add_action( 'woocommerce_new_coupon', 'after_new_coupon_created', 10, 2 );
I'm using the WordPress plugin Ultimate member which has a hook called um_user_register which should happen after a user fills out a registration form. According to the documentation (https://docs.ultimatemember.com/article/1308-umuserregister) I should be able to use that hook and do my thing. Unfortunately nothing happens.
The code I have added to my theme's functions.php file:
//Ultimate Member - Extra stuff after user registers
add_action( 'um_user_register', 'my_user_register', 10, 2 );
function my_user_register( $user_id, $args ) {
add_user_meta( $user_id, 'user_utlimate_member_signup', 'Yes');
}
Am I putting my add_action or function in the wrong place or is there something I'm overlooking?
I'm developing a plugin over woocommerce. I want when a order is completed some custom fields to be filled. After that I want to add those custom fields to the email sent to the client.
I have used
add_action( 'woocommerce_order_status_completed', 'myplugin_woocommerce_order_status_completed', 10, 1 );
to fill the custom fields and
add_action( 'woocommerce_email_order_meta', 'woo_add_tickets_numbers_to_email' );
to add those fields to email.
My problem seems tha woocommerce_email_order meta get fired before woocommerce_order_status_completed and the fields are empty.
How can I force to execute first woocomerce_order_status_completed and send email after that?
Best regards
There is one way available to call "woocomerce_order_status_completed" this action before email send.
You can try using this code to trigger this function first,
add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ), 10, 2 );
instead of,
add_action( 'woocommerce_order_status_completed', 'myplugin_woocommerce_order_status_completed', 10, 1 );
Using the [woocommerce_checkout] shortcode (do_shortcode('[woocommerce_checkout]') in my Ajax-loaded PHP code) I can display the checkout form wherever I want. But payment methods are missing. How can I have these too?
If you are not calling the ajax from cart or checkout page you need to set WOOCOMMERCE_CHECKOUT = true before calling shortcode;
define( 'WOOCOMMERCE_CHECKOUT', true );
echo do_shortcode('[woocommerce_checkout]');
I think this is a bug.
I've reviewed the code and found out that <?php do_action( 'woocommerce_checkout_order_review' ); ?> on form-checkout.php is not able to run the hook add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); if using shortcode [woocommerce_checkout].
I would like to Hide below message you see on dashboard after wordpress version upgrade in Wordpress MU.
I know for hiding version upgrade notice there is one filter as
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
But I want to disable the following notice
"Thank you for Updating! Please visit the Update Network page to update all your sites."
This message was fired on two hooks.
add_action( 'admin_notices', 'site_admin_notice' );
add_action( 'network_admin_notices', 'site_admin_notice' );
Remove this and you remove the message, use remove_action.
To remove this function use a function, like the follow example.
add_action( 'admin_menu','fb_hide_site_notice' );
function fb_hide_site_notice() {
remove_action( 'admin_notices', 'site_admin_notice' );
}