API calls on plugin activation or init?
on the plugin activation hook, instead of doing everything right there just set a cron job that will do it.
on the plugin activation hook, instead of doing everything right there just set a cron job that will do it.
The short answer is: There is no code that’s being excuted The long answer is: You are suppose to define that code in your own plugin space. You add a activated_plugin hook and within the callable function you specify you define the things you want to happen when your plugin is actived, ie: create database, … Read more
Users set passwords but cannot login
That was my fault! The problem is copy_dir isn’t a WP_Filesystem method, so it cannot be called as an instance of WP_Filesystem like this: $wp_filesystem->copy_dir(), but independently like this: copy_dir(“source”, “destination”) after the WP_Filesystem() has already been called and setup. Reference copy_dir
You might have missed the right configuration in your hosts file. Assuming you are using Apache on a Linux server and vi editor, open this file: sudo vi /etc/apache2/sites-available/example.com.conf Since you have installed Multsite as subdomains, adjust your directives to include these: Listen 80 <VirtualHost *:80> DocumentRoot “/var/www/example” ServerName example.com ServerAlias *.example.com </VirtualHost> Note that … Read more
<?php /* Plugin Name: Activation Description: This display notice message test plugin Author: Nanhe Kumar Version: 1.0 Author URI: http://nanhe.in/ */ class Activation { public static function init() { add_action(‘admin_notices’, array(__CLASS__, ‘text_admin_notice’)); } public static function text_admin_notice() { ?> <div class=”notice notice-success is-dismissible”> <p> TEST MESSAGE</p> </div> <?php } } add_action(‘init’, array(‘Activation’, ‘init’)); Your message … Read more
Your local server probably has problems sending mail. There are ways to fix that, but it is probably easiest to change the password in the database directly. Since you’ve made a copy of your site I am going to assume you have access to the database through something like PhpMyAdmin. Follow these instructions to change … Read more
I found the solution ! The problem was I loaded plugin domain only when plugins are loaded, not for the activation plugin. It resolves my problem… MyPLugin.php class WPGroupSubs { public function __construct(){ // Install needed components on plugin activation /* need to add this */ register_activation_hook( __FILE__, array( $this, ‘load_text_domain’ ) ); register_activation_hook( __FILE__, … Read more
In this case, “nht_” is a prefix to avoid naming collisions with similar functions. This is a “best practice” to observe when doing your own development. So if you’re developing something that would be distributed publicly, you should be the habit of applying your own prefix to your function names; and since this particular code … Read more
Since the standard redirection works, I figured the conflict must be with TGM plugin activation already hooking to activated_plugin and producing output and thus preventing the redirect… Therefore the solution was to ensure that the plugin activation function hook was added to an earlier priority than the (silent) default of 10 most probably used by … Read more