Comment Approve – Add custom function when comment is approved

Sadly there are no hooks or filters that you could use in edit-comments.php. You’d have to build your own admin page with a custom button and use wp_set_comment_status( $comment, ‘approve’ ); to approve comment and do whatever you need to do… EDIT: I was wrong – there’s the wp_set_comment_status action inside wp_set_comment_status function https://wpseek.com/function/wp_set_comment_status/ do_action( … Read more

How to reinstate previously saved option?

The only way WordPress is going to know what the previous option was, is if you save it before you change it – since you’re replacing the built-in option, it has no way of knowing how to get back to that. So, you could add a custom ‘backup’ option that you restore on deactivation. Something … Read more

Username Variable in custom links?

The User data of the currently logged in user in WordPress can be retrieved via wpget_current_user() So you should be able to do something like this in your theme or wherever. $current_user = wp_get_current_user(); echo ‘<a href=”http://example.com/members/’ . $current_user->user_login . ‘/profile”>Your profile</a>.’; And build your link that way. HTH

Ajax object not defined – JS file is in plugin folder

You have registered your JS code in wrong hooks . Always CSS and JS should be registered using wp_enqueue_scripts. Also you have only registered your JS code. You have not enqueued your JS file using wp_enqueue_script( ‘ajax-send-notification-script’ ); function ajax_send_notification_init(){ wp_register_script( ‘ajax-send-notification-script’, plugins_url() . ‘/plugin-name/js/the-plugin.js’, array(‘jquery’) ); wp_localize_script( ‘ajax-send-notification-script’, ‘ajax_send_notification_object’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ … Read more

Update-safe translating of single text string in plugin

to use the file wp-content/languages/plugins/albdesign-wc-donations-uu_UU.mo in the plugin, it has to be declared like that : load_plugin_textdomain(“albdesign-wc-donations”); // search in wp-content/languages/plugins/ // search in the plugin files if not found in wp-content/languages/plugins/ load_plugin_textdomain(“albdesign-wc-donations”, FALSE, plugin_dir_path(__FILE__) . “languages/”); is it’s not the case, you can create another plugin to correct that loading of the translations files

Add the_post_thumbnail_url to a shortcode in function.php

I think you’re just printing your function as a string, try concatonating: add_action( ‘woocommerce_product_meta_end’, ‘childReview’ ); function childReview() { global $post; echo do_shortcode(‘[cl-popup size=”l” title=”Click!” btn_label=”Headline” btn_bgcolor=”#006982″ btn_color=”#ffffff” overlay_bgcolor=”rgba(0,105,130,0.75)” title_textcolor=”#006982″ content_textcolor=”#006982″]<img src=”https://wordpress.stackexchange.com/questions/235313/” . wp_get_attachment_url ( get_post_thumbnail_id( $post->ID ) ) . ‘”/> [/cl-popup]’); }

wp_localize_script not passing the data

As it stands, your shortcode will be executed after wp_enqueue_scripts — when the post content is output. That’s why the data isn’t available to your scripts during wp_enqueue_scripts for wp_localize_script. wp_enqueue_script( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, bool $in_footer = false ) You would; A) Need to … Read more

Redirect logged in user to somepage on every page view?

I would utilize the user meta info and ‘wp’ hook for this. You can use a function similar to below: add_action( ‘wp’, ‘wpse69369_special_thingy’ ); function wpse69369_special_thingy() { if ( is_user_logged_in() && “” == get_user_meta( get_current_user_id(), ‘completioncheck’, true ) ) wp_redirect( string $location ); exit; } } Then when the user completes the action necessary you … Read more