How to create plugin auto create page wordpress?

The following hook is called when the plugin is activated from the dashboard. register_activation_hook( __FILE__, ‘myplugin_activate’ ); function myplugin_activate() { //create a variable to specify the details of page $post = array( ‘post_content’ => ‘content’, //content of page ‘post_title’ =>’title’, //title of page ‘post_status’ => ‘publish’ , //status of page – publish or draft ‘post_type’ … Read more

same user role or copy the user role to be same as the other role

Contributor has the following capabilities delete_posts edit_posts read You can create the “Seller” role to have same capabilities as Contributor add_role( ‘seller’, __( ‘Seller’ ), array( ‘read’ => true, ‘edit_posts’ => true, ‘delete_posts’ => true, ) ); Warning from codex NB: This setting is saved to the database (in table wp_options, field wp_user_roles), so it … Read more

Deregister scripts from plugin

There’s a much better and more reliable way than naming your plugin “ZZ” – use a delayed hook on plugins_loaded, which fires after all plugins are loaded: function wpse_191178_plugins_loaded() { // Do your stuff } add_action( ‘plugins_loaded’, ‘wpse_191178_plugins_loaded’, 100 );

BuddyPress: filter member based on Xprofile Field

Try: class BP_Custom_User_Ids { private $custom_ids = array(); public function __construct() { $this->custom_ids = $this->get_custom_ids(); add_action( ‘bp_pre_user_query_construct’, array( $this, ‘custom_members_query’ ), 1, 1 ); add_filter( ‘bp_get_total_member_count’, array( $this, ‘custom_members_count’ ), 1, 1 ); } private function get_custom_ids() { global $wpdb; //figure out if the logged-in user is engineer or it $s = xprofile_get_field_data( 2, bp_loggedin_user_id() … Read more

WordPress Custom Menu Admin helper plugin

Add this to functions.php, or put the CSS into a css file which is loaded in the admin screen. This will let the box become resizable, so you can make it taller and see more pages/checkboxes at once. function wp191833_resize_menu_list() { ?> <style type=”text/css”> #wpwrap .categorydiv div.tabs-panel, #wpwrap .customlinkdiv div.tabs-panel, #wpwrap .posttypediv div.tabs-panel, #wpwrap .taxonomydiv … Read more

Call Ajax URL in Plugin

Put below code in _construct() function and change action name to get_product_serial_callback :- add_action( ‘wp_ajax_get_product_serial_callback’, array($this,’get_product_serial_callback’) ); add_action( ‘wp_ajax_nopriv_get_product_serial_callback’, array($this,’get_product_serial_callback’ ));

Enable Shortcode for Custom Wordress Widgets

Your shortcode function will register widget, will not display on a page as a shortcode. To show widget on a page/post you need to use the_widget( ‘test_widget’, $instance, $args ); function. Codex documentation is here For example, in your code // Display the widget function test_show_widget() { the_widget( ‘test_widget’ ); } add_shortcode(‘test_widget’, ‘test_show_widget’);