populating a form field with output from a custom plugin function

You can pre-populate a field with gform_field_value_$parameter_name hook, where $parameter_name is the name of the field/parameter. So, for example if you added that to your code: add_filter(‘gform_field_value_invoice_numb’, ‘my_func’); function my_func( $value ) { return do_shortcode(‘[ABC_form_number length=”13″ char=”num” case=”false”]’); } (Note: Allow field to be populated dynamically option needs to be enabled)

Ajax is not working in a loop

Your code has var getid = $(‘#my-categorychecklist input:checked’).last().val(); see the .last(), that’s why you’re only getting the last item Also, why do you have the same thing in getid and matchid? You need to store the selected categories in an array and loop through them, try something like: var selected_cats = $(‘#my-categorychecklist input:checked’).map(function() { return … Read more

Plugin does not add action

Activation hook is run only after the plugin get activated. So only once and only during that one request. It’s meant to allow author of a plugin to perform some actions after the plugin is activated. Actions, that need to be done only once. For example if your plugin uses custom database table – you … Read more

Issue running db create table query from static method

plugin_dir_url() returns the URL directory path for your plugin, so this won’t work as expected (the function won’t be called): register_activation_hook(plugin_dir_url(__FILE__) . ‘frequentVisitorCoupons.php’, ‘Utilities::createTablesIfNotExists’); You should have used plugin_dir_path() which returns the file-system directory path for your plugin (e.g. /var/www/public/<user>/wp-content/plugins/your-plugin/). But if the code is in the main plugin file, then you could simply use … Read more

Delete option of a Plugin

WordPress will popup for FTP credentials if it does not have permission to write the files it needs to. Am assuming your WordPress website is hosted on Linux OS. And also if you connected to your server using SSH (i.e., putty, etc.). Please try to run the below command: sudo chown -R www-data:www-data /var/www/html Alternate … Read more

How to create a page with a form programmatically in WP?

You can use wp_insert_post() function with ‘after_theme_setup‘ action hook to programatically create pages. Here is a short example, add_action( ‘after_setup_theme’, ‘create_form_page’ ); function create_form_page(){ $title=”Form”; $slug = ‘form’; $page_content=””; // your page content here $post_type=”page”; $page_args = array( ‘post_type’ => $post_type, ‘post_title’ => $title, ‘post_content’ => $page_content, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_slug’ => … Read more