Hooks and filters guide
-
Hello NotificationX devs!
I was trying to search more information on the available hooks and filters of this plugin, but I could not find any. Can you please let me know if you have any documentation on the hooks and filters of this plugin? Basically a developers documentation what I am looking for is.
Thank you.
-
Hi @amitbiswas06,
Greetings. Thanks for reaching out to us.
Actually, We don’t have any documentation right now. We have plans to create one in the future.
But If you have any specific needs we can provide the necessary hooks.
Thank you!Hello Amit,
Thanks for your quick response. I am trying to create an add-on to integrate my plugin CQFS with the NotificationX plugin. So, whenever a quiz/feedback form is submitted, I can show the notification. Please throw some light on this.
Thank you for this brilliant plugin.
-Amit
Hi @paulamit,
I have successfully created an extension for the plugin on my own. However, I still need more information about the extension and hooks, especially regarding the front-end view and content fields.
Thank you,
AmitHi @amitbiswas06,
You can extend our ‘Extension’ class to add a custom ‘SOURCE’,? and you can use the ‘Contact Form’ type for your plugin.
also, you can see how we have added?CF7?and?WPForms?by extending ‘Extension’ Class.
Extension.php
Hope it helps. Thank you!
Best Regards,
Amit PaulHi @amitbiswas06,
Hope you’re doing well. Have you checked the above-provided info yet? If not, kindly check, please. Also, let us know if there is anything we can assist you with.
Thank you!Hello @paulamit,
Thanks for your response. I have checked those files and I have successfully created an extension. However, there are few areas that are still dark for me. Such as front end template fields, link option for type “form” in admin contents, hook custom fields for the extension, remove ajax loading for the second field in content, etc. I can send you a detailed report tomorrow.
Thanks.
Hello @paulamit,
Can you tell me more about this method –
public function restResponse($args){}
This method is loading form tags via ajax call as soon as the first parameter (select a form) is switched. How can I disable the first parameter dependency and remove ajax loading as I want to use pre defined fields? Apart from this, how can I customize notification templates (front end) or use my own template/theme?
What are the usage of
public $templates = [];
andpublic $themes = [];
in the abstract class Extension?Please let me know if you can help. Thank you.
-Amit
Hi @amitbiswas06,
Hope you are doing well. I have checked your query. Please find the details in below:
To Disable ajax pull:
add_filter('nx_notification_template', [$this, 'notification_template'], 9);
public function notification_template( $fields ){
unset($fields['first_param']['ajax']);
return $fields;
}public $themes = [];
?contains mainly default value for that specific theme, Notification Template default value, screenshot to show in theme tab etc.?$themes[]['defaults']
?set any value for other fields.$this->templates
?includes values a dropdown contains.?$this->templates[]['_themes']
?the values should be included in only the themes listed.Hope this will help you. Let us know if you have any other queries.
Thanks!
Hi @arrasel403,
I appreciate your help. Yes, I have tried the
nx_notification_template
filter exactly the same way. But it is unsetting the Ajax call for all other “form” extensions available by default. Please advise me on how I can achieve this only for specific extensions. I can disclose more issues once I receive your response on this.Thanks,
-AmitHi @amitbiswas06,
Hope you are doing well. You can use the any of the shared code in below:
add_action('init', function() {
remove_filter('nx_form_list', [\NotificationX\Extensions\CF7\CF7::get_instance(), 'nx_form_list'], 9);
});or
add_filter('nx_notification_template', function( $fields ){
$fields['first_param']['ajax'] = Rules::is('source', 'cf7', true, $fields['first_param']['ajax']);
return $fields;
}, 99);Hope this will help you. Let us know the update.
Thanks!
Hello @arrasel403,
Thanks for the code. I have used the second one instead of removing the filter. It is working correctly and selectively. I am now trying to add custom options for the second dropdown. I do not need the public
function restResponse($args) { }
anymore. Previously I was adding custom options via the restResponse function. How do I add new options for the second dropdown now? While I am still studying the code, your help would be appreciated.Apart from this, I have included custom links for the notification template by using the following code –
add_filter('nx_link_types', [$this, 'link_types']);
public function link_types( $options ) {
$options = GlobalFields::get_instance()->normalize_fields(
array(
'cqfs_link' => __( 'CQFS Link', 'notificationx' ),
), 'source', $this->id, $options
);
return $options;
}The above code is working correctly, but how do I activate this for my extension?
Thanks,
Amit-
This reply was modified 7 months, 1 week ago by
Amit Biswas.
Hi @amitbiswas06,
Hope you’re doing well.
I suggest you, In your extension add the filter in?init_fields
?function. If you already don’t have one then create one.
Here is an example:
https://github.com/WPDevelopers/notificationx/blob/20ce9d9f7efaab18bd59ed2a1c091b57aae1b0d3/includes/Extensions/EDD/EDD.php#L59-L62public function init_fields(){
parent::init_fields();
add_filter('nx_link_types', [$this, 'link_types']);
}Also, please let us know?if you created the extension successfully or not?
Thanks!Hi @paulamit,
I am not sure about this solution since I have successfully created link as drop-down. But the extension type “form” do not support any links on the notification. I want to activate it for form type extensions. Sorry, for misunderstanding. Looking forward to your help.
P.S. – Yes, I have created a new extension successfully, but I need more technical help to make it full potential addon.
Thanks.
Hi @amitbiswas06,
Really sorry for the misunderstanding.
Well, adding?thispublic $link_type = 'cqfs_link';
? property to your extension class will set?cqfs_link
?as default value for?Link Type?dropdown when you select your source.You can see example here:
Types:?https://github.com/WPDevelopers/notificationx/blob/b97ea57d9551b3214ff13592277afa8bffa1bb08/includes/Types/Comments.php#L32
Extension:??https://github.com/WPDevelopers/notificationx/blob/4b75b47c512c60972da7c547a6a9fa890a131561/includes/Extensions/Google/GoogleReviews.php#L35You can find code responsible for setting the default value here:?https://github.com/WPDevelopers/notificationx/blob/e31ed19f0eb71d24508214f23b9f1978b52c0cff/includes/Extensions/Extension.php#L214
Hope it helps. Thank you!Hi @amitbiswas06,
Hope you’re doing good. We haven’t received any?feedback from you. Did you check our above information? Is that helpful for you? Kindly, let us know the update.
Looking for your response.
Thank you! -
This reply was modified 7 months, 1 week ago by
- The topic ‘Hooks and filters guide’ is closed to new replies.