Tag Info

New answers tagged

0

Use the admin-post action hook to intercept POST requests and process forms. The admin_url() function can be used to output the correct URL, and use wp_redirect() to redirect back to your plugin page after processing. And do yourself and your users a favor- don't reinvent wheels and add tables when the native tables and API can be used.


4

You can clearly see the way WordPress loads plugins if you inspect the source code of the file wp-settings.php. The function wp_get_active_and_valid_plugins() loads plugins for individual sites in the network and for non-Multi-Site installations, while wp_get_active_network_plugins() loads network activated plugins when Multi-Site is enabled. The former ...


4

Wait for the action plugins_loaded before you create the class instance. The pluggable functions are loaded at this time. From wp-settings.php: /** * Fires once activated plugins have loaded. * * Pluggable functions are also available at this point in the loading order. * * @since 1.5.0 */ do_action( 'plugins_loaded' ); I would even wait for ...


1

The simplest and quickest solution would be to use the add_rewrite_endpoint function. <?php add_rewrite_endpoint( $name, $places ); ?> So in your case it would be something like this: add_rewrite_endpoint( 'user', EP_PERMALINK | EP_PAGES ); An user URL would look like this: http://www.example.com/my-page/user/john To access the variable: ...


1

You can hook onto pre_insert_term, check the taxonomy and whether or not the user has the specified role as follows: function disallow_insert_term($term, $taxonomy) { $user = wp_get_current_user(); if ( $taxonomy === 'post_tag' && in_array('somerole', $user->roles) ) { return new WP_Error( 'disallow_insert_term', ...


0

It looks like your theme or a plugin installed is preventing a script from being executed when a user is not logged in. It may seem like the problem you described above, but it is not an error. When I try to send a POST request, not logged in, to the following URL: http://solaglobal.com/wp-admin/admin-ajax.php It returns the following HTTP code: 302 ...


0

wp_ajax_{my-action} action hook is only for admin side. For frontend you must use wp_ajax_nopriv_{my-action}. You can combina both if the ajax action is for both sides. For example: add_action('wp_ajax_filter_search', 'filter_search_result'); add_action('wp_ajax_nopriv_filter_search', 'filter_search_result'); Also, don't forget, never, to die or exit at ...


0

I have fix this issue in my site for set bellow value in php.ini file memory_limit = 128M upload_max_filesize = 80M post_max_size = 80M may be this useful.


7

The problem I think the problem here is that you're generating an infinite loop, by placing wp_mail() inside the $phpmailer->action_function callback, that fires after each email. Each time you send an email with wp_mail(), you call wp_mail() again, and again, and again ... etc Possible workaround You should instead use, for example, the following ...


0

So, to answer my own question. In the functions/backend code I made a mistake with this line: 'id' => $prefix . 'media_embed', In a repeater field it it doesn't need the prefix and as that is defined in the parent and so it should be: 'id' => 'media_embed', And for the front end this line: <?php $value = get_post_meta( get_the_ID(), ...


0

You should run your register_activation_hook after creating object. class Notification { function jal_install() { global $wpdb; global $jal_db_version; $table_name = $wpdb->prefix . 'fnotice'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE ...


0

This is not a casual task, nor do I think will you be able to find a free plugin to do that for you. How are your PHP skills? If not so much (and based on the casual way you've asked the question) I'm assuming they are zero, you will need to write up a specification for what you want, then pay a developer to create the product for you.


1

For non-hierarchical terms (such as tags), you can pass either the term name or id. If you pass the id there is only one caveat: You must pass it as an integer, and it must be in an array. This is necessary because any non-array value passed will be converted to a string, which will be interpreted as a term name. $tag = '5'; // Wrong. This will add the tag ...


1

There is problem with the "wordpress-seo" permission so please following steps. There are two way 1) Upload from the wp-admin Step 1 -> Change the "wordpress-seo" permission or rename the "wordpress-seo" plugin to another Step 2 -> If you have change the permission then just upgrade the plugin and if you have rename the plugin dir then you need to ...


0

In simple words "NO" it is not recommended until one plugin is not a subset of another plugin. If you want multi-language use different. Thanks, Vee


1

You are saving data to an option named my_option_name so your attempt to retrieve data from an option named $this->options['title'] isn't going to work. You will need something like this: public function DataToget($field = '') { if (empty($field)) return; $jugHigh = get_option( 'my_option_name' ); if (!isset($jugHigh[$field])) return; return ...


4

First thing to mention is that you don't need to use wp_register_style if enqueuing within the same function. You can replace it with wp_enqueue_style and remove the duplicate. As for why your stylesheet isn't loading, start by checking the file path. Try this instead: wp_enqueue_style('cl-chanimal-styles', plugin_dir_url( __FILE__ ) . ...


0

You misunderstand what page_template does. It does not create a new template that you will "show up" somewhere and that you can use. It replaces the page.php template provided by the theme. I think that what you want is template_redirect: function custom_page_template( $page_template ) { if (is_home()) { get_header(); echo 'do stuff'; ...


0

You don't echo content from a filter, you return it. You should have: function addOptions($post_id){ $post = get_post($post_id); return $post_id; } add_filter('mbdb_book_grid_after_link','addOptions'); See: http://wordpress.stackexchange.com/a/113760/21376


1

Scripts should be enqueued on wp_enqueue_scripts action hook, which runs after init action. So dequeuing on init won't work because sripts are not enqueued yet. Before enqueued scripts are printed, wp_print_scripts action is triggered so you can dequeue or unregister scripts safely at this moment: add_action( 'wp_print_scripts', 'drw_timelinr_dequeue' ); ...


0

If loadScripts() is registered/enqueued correctly (the code posted doesn't show the hook used) then is it enqueued on wp_enqueue_scripts which runs well after init so what you are doing is trying to remove something that hasn't been added yet, and will be added later. Assuming that: add_action('wp_enqueue_scripts', 'drw_timeline_js', PHP_INT_MAX); ...


0

You are probably confusing resources and disk space. A website and its plugins requires almost no disk space. But all your visitors takes up a lot of resources - CPU, RAM, NETWORK etc. If you are experiencing problems regarding to network traffic, you could move your images to a CDN. Google can help you in this matter. Having trouble with CPU & RAM ...


0

A useful tool to do this is: WP-CLI - WordPress Command Line Interface. You can list all plugins, activate, deactive, install, uninstall, and/or update one or more plugins using a script. A huge timesaver.


1

Use is_page(). The is_page() function accepts page title, slug or id. Documentation <?php if(is_page('myscript')) { include '/path/to/myscript.php'; } ?> UPDATE To add it to the content, you have two options 1. Find the content function in your template Find either the_content() or get_the_content() in your template. Place it immediately ...


1

Put code below into your theme's functions.php: add_action( 'template_redirect', function() { is_user_logged_in() || auth_redirect(); }); function fpw_custom_login_message() { $message = '<p style="text-align: center">Until this site goes public you need to be registered to see the content<br />&nbsp;</p>'; return ...


1

Both DataTables Editor and WordPress are trying to use the same reserved parameter, 'action'. WordPress is using $_REQUEST['action'] to route the request in admin-ajax.php line 86. DataTables Editor is using $_POST['action'] to tell the server-side processing script what action to apply ( insert / delete / update - see: ...


0

Since every author, category, tag, ... already has a feed, it could just be as simple as setting this up with a service like Feedburner or Feedblitz and perhaps masking it using Pretty Link. The Codex also explains this quite well in my opinion. Hope it helps!


0

Yes, multisite is not what you need here. I would try to map all subdomains on the same wordpress install, and then customize the template via the current URL. In the wp-config.php you then use the current URL as base url: define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); You can also do ...


0

Have you tried adding the unfiltered_upload capability too? function add_theme_caps() { // gets the author role $role = get_role( 'subscriber' ); $role->add_cap( 'upload_files' ); $role->add_cap( 'unfiltered_upload' ); } add_action( 'admin_init', 'add_theme_caps'); add_action( 'init', 'add_theme_caps');


1

you can override the shortcode like this : add_action("init", function () { remove_shortcode("timelinr"); add_shortcode("timelinr", function ($atts, $content) { // call the shortcode of jqueryTimelinrLoad $result = $GLOBALS["jqueryTimelinrLoad"]->shortcode($atts, $content); // dequeue style ...


1

The reason the link isn't working is because you haven't formatted it correctly. This: return '<h3><a href="www.google.com">Hello World</a></h3>'.$content; Should be this: return '<h3><a href="https://www.google.com/">Hello World</a></h3>'.$content; To answer your other question: There are a lot of ...


2

The plugin you mentioned is only reportedly tested up to WordPress version 3.6.1. I would not (in general) recommend abandoned plugins, because they might impose security risks. Additionally it uses PHP4 class constructors, that might soon be deprecated and it calls non static methods in a static way. If you remove the plugin, you should be able to use ...


-1

I have not tested but the following code will help you please add the following two lines of code to your function.php file $role= get_role([role_name ]); $role->add_cap('upload_files');


0

It is not advisable to run anything but the latest wordpress, especially with regards to security fixes. For a minior wordpress release, you can read the release notes and see if any of the changes are security related. If they aren't, then you can probably safely wait until the next security fix. In my experience, wordpress updates only sometimes break a ...


0

Could the same functionality be achieved with Transients? i.e.: set_transient( 'username', $_POST['firstname'], MINUTE_IN_SECONDS ); Sessions are not necessary then.


1

Just extend your search form with a hidden input: (notice the last input field) <form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>"> <label> <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span> <input type="search" ...


1

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 );


0

Since plugins are loaded by the alphabetical order of plugin's folder name (not by plugin's name), name your plugin folder ZZ.. and it should load last :-)


-1

You can usually specify the post type in WP_Query. Woocommerce is product Wordpress posts is post


2

You should use pre_update_option_{option_name} filter. Example:- function system_save_number( $new_value, $old_value ) { mail('my@email.com','here',print_r($old_value ,true) . "\n\n" . print_r($new_value,true)); return $new_value; } function system_init_actions() { add_filter( 'pre_update_option_system_number', 'system_save_number', 10, 2 ); } ...


3

You'll need to log onto your FTP server and goto the wp-content folder -> plugins -> and delete the GZIP plugin you have installed. If you are not sure about FTP, you can probably try and go through your web server control panel, they usually have some sort of file browsing option. You might also need to check the .htaccess file also, but just try removing ...


0

If your user is logged in, you can use meta fields for users. https://codex.wordpress.org/Function_Reference/add_user_meta


0

So I thought, maybe, there is a WP feature that WP stores some data per user session so that all plugins (php, and javascript code as well) can use the data. Per session? No. Wordpress does not use sessions, though you can initialize a session if you want. The only user data set per session (sort of) are the login cookies. Most other data is stored ...


0

Found it - it was a bug in the plugin itself: https://wp-types.com/forums/topic/commercial-tab-not-showing-to-register/


2

Try this code $crop = array( 'center', 'center' ); $resize_img->resize( $wpc_image_width, $wpc_image_height, $crop);


0

write this code in front page to check user is login or not: if ( is_user_logged_in() ) { ... }


0

The CheckLoginCookie() function will help you to get the current login username you can get the username by using bellow code $UserCookie = CheckLoginCookie(); $username = $UserCookie['Username']; if($username){ // User Login }else{ // User Not login }


0

Hope this will helful to you global $current_user; // Use global get_currentuserinfo(); // Make sure global is set, if not set it. if ( user_can( $current_user, "subscriber" ) ) echo 'User is a Subscriber'; else echo 'User is not a Subscriber';


3

The short answer is that you can't force people to register a plugin. Because it's written in PHP, anyone with a modicum of PHP knowledge can get into the code and bypass any checks you put in there. That being said, there are three routes you can take to monetize it: Move some of the critical functionality to an external server. Users have to register to ...


0

Reading and writing to a file is going to be dicey. You are going to be fighting with file permissions if you save anywhere but the wp-content/uploads directory (and it looks like you want to save to the plugins directory). If you have sufficient control of the server, you may get this to work by editing permissions in the plugins directory, but I wouldn't. ...



Top 50 recent answers are included