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

robthirlby on "format of user_email field"

$
0
0

Is there a legal hack to change the validation of user_email fields to allow say rob<rob@thirlby.net> or rob(rob@thirlby.net)? I'm unclear why the validation via is_email() is so restrictive effectively to name@domain.


Erfo on "Latest posts with same terms of the current post"

$
0
0

Hi.
Inside of an article, I'd like to show the latest 3 recipes with the same "ingredients" of the current post.
I have this code:

$terms = get_the_term_list( $post->ID, 'ingredients' );
$args = array(
        'posts_per_page' => 3,
        'post_type' => 'recipe',
        'tax_query' => array(
                array(
                    'taxonomy' => 'ingredients',
                    'field' => 'slug',
                    'terms' => array( $terms )
                )
            )
        );
$the_query = new WP_Query( $args );

The variable $terms is not correct, I wrote it for example...

How can I show 3 posts whit the same terms of the current post?
Thanks.

kokojambo on "Assign tags to users"

$
0
0

Hello there,

I would be grateful if you could help me doing this:
I want my WordPress users to be able to assign tags to their profile page(tag cloud), by adding keywords in the “edit profile” page.
And I want WordPress to automatically assign tags from posts the users created- to their profiles.

Something with taxonomies/the_terms/user_meta_data(?)

Also if you know about any plugin that may help me- please share :)

Thanks and have a great day!

GoodMusicInc on "Weekly popular posts"

$
0
0

Im looking to make my popular post widget on the sidebar take into account the most popular posts on a 7 day range rather than since it's been installed. How do I do that? My site is goodmusicinc.net

Here is the area of the code the developer said to change, since then he has been no help -

* @param bool $display_popular_icon - Display the popular posts icon.
* @param int $popular_icon_size - The size of the popular posts icon.
* @param int $popular_amount - The amount of popular posts to display.
* @param int $popular_chars - The number of characters to display per post.
* @param bool $display_popular_view_count - Display the popular view count.
* @param string $popular_tab_post_type - The post type to display the posts for.
*
*/
public function aaw_get_most_viewed_posts($display_popular_icon = true, $popular_icon_size = 50, $popular_amount = 5, $popular_chars = 35, $display_popular_view_count = true, $popular_tab_post_type = 'post') {
$post_views = '';
$post_title = '';
$out = '';

$args = array(
"posts_per_page" => $popular_amount,
"post_type" => $popular_tab_post_type,
"post_status" => "publish",
"meta_key"	 => "aaw_views",
//'meta_value_num' => '0',
"orderby" => "meta_value_num",
"order" => "DESC"
);

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

jeich on "get_queried_object no longer working with pre_get_posts and pretty permalinks"

$
0
0

Hi!

We are experiencing the category issue referenced here ->https://core.trac.wordpress.org/ticket/26627

We applied '3.8.1' and the issue is still unresolved.

The custom query is operable with the default permalink (?cat=) option set. Our mobile barcode scan now returns the homepage. Does anyone feel up to a challenge?

maheshwarimani1991 on "Get_user_meta not working in my plugin"

$
0
0

i am using get_user_meta() function in my plugin but it is not showing any values for usermeta table, it is showing blank result.

I am able to see the value present in phpmyadmin. I am using it in a plugin add_action('user_register','user_sf_lead'), but it is not showing any value in my code.

I am able get all the value of USER table but no values from USERMETA table in my plugin.

When updating my user i am able to get all values.

How to get values from get_user_meta while using action hook
add_action('user_register','user_sf_lead')

Also when get_userdata , i getting values from USER table but not from USERMETA table.

$user_info = get_userdata($user_id);
'Name' => $user_info->ID,
'First_Name__c' => $user_info->first_name,

Provide solution??

vbmark on "Advantages/disadvantages to multiple meta tables for a Wordpress app?"

$
0
0

I am working on a web application where I am using Wordpress' EAV. But not from a post, page template or plugin; this is my own stand-alone page.

What I cannot figure out is if there are pros and cons to adding all my app's data to the usermeta table or should I create a separate, custom meta table.

I will have users that can log in and let's say, for example, that each use can enter a list of planets and each of their planets have countries and each their countries have states.

I know I can just put all this in the usermeta and use keys of planet, country, and state. But would a separate table such as wp_planetmeta provide any advantages or disadvantages?

Or, would it be even better to create three separate meta tables such as wp_planetmeta, wp_countrymeta, and wp_statemeta?

I cannot find any information related to this issue. Side note, I do not need to query on the values.

Thanks.

DanneSWE on "Some upload vulnerability"

$
0
0

We have a site that has been a victim for some hacking attacks.
The attack is quite strange, at least for me. The hackers were able to upload a file with the filesman backdoor. Usually this backdoor is somewhere implemented in a sourcecode/plugin/theme file. I had no ideas how they managed to get that file in there. It was placed in the www-root.
So, we downloaded a brand new copy of wordpress, I checked the theme for obvious backdoors/vulnerabilities and so on, removed all files in the www-root, changed all the passwords (for MySQL, FTP etc), removed all users in the db and implemented a new admin user with a new 16 chars password. We set all the writing permissions to ALL folders so that nobody except the owner could do anything, set very restricted permissions in .htaccess. I also set the define('DISALLOW_FILE_EDIT', TRUE); in wp-config.php. And we went live... And it was hacked again.
I did how ever look at the startpage hitting F5 to see if it went down, and suddenly I saw an file upload form on the top of the page. I have no clues how they managed to get that form there. How could they manage to get a form there?! The file edit was disabled? They ran the file, deleted all files, the whole DB and put a "hacked by.." index.html in the root.
So we did all the stuff mentioned above one more time, and set the db users permissions to read only. After that, they could not do anything (they could upload the file tho) but they could not do anything. And this obviosly means that noone can update the page as well.

The only thing we did not re-create was the database. I did how ever try to read it for strange stuff manually, but found nothing.

So, now I've created a new local database from scratch. At the host I've prepared a brand new database with this new stuff from my local machine. In this new DB I've manually copy/pasted all the pages (by clicking "create new page" for all pages). I've set another db prefix. The theme is completely re-written and contains nothing strange at all. The default themes are removed.

The version we were using was 3.7 and the plugins were:

  • Baw anti CSRF
  • TinyMCE Advanced
  • Display widgets

Now we're on WP 3.8 with the same plugins.

Is there any known issues with these plugins? Is there any function in the theme that I could use wrong and exploit this vulnerability?

We're trying to get this stuff online in some hours. If there was a backdoor vulnerability left, my guess would be that this was some where in the DB. Which is brand new this time.

If this would fail again, what would my next step be? Changing the host?! We were in contact with them to see if there was anything bad with the account, but they said it looked all right. If it was my own web server i would re-install it. But we don't have that option now.

Any help at all is appreciated.


idomaron on "Counting custom post type in every categories"

$
0
0

Hello everyone
I am trying to display, in one page, the number of posts I have in each one of the categories (AKA 'count'), but I must differentiate them by post-types. Example:

Economy: 10 books, 7 movies, 12 events.
Health: 7 books, 8 movies, 2 events.

What would be the best way to do so?

Thank you

nat@cry on "Use if post has tag auto generate link to page"

$
0
0

Hi

I am trying to create a function where if a post has a certain tag, generate a link to a certain page.

Can anyone help with this please my attempts at creating the PHP are failing.

Also I am guessing that I should be adding this to the single.php for this to work.

Any help would be greatly appreciated, plus you would be helping a charity.

Thanks

RaylaDevine on "How to Create a Grid of Posts on Pages"

$
0
0

I'm trying to create grid like this or maybe even something simple like this . I used the grid widget in the Visual Composer plugin and I was OK with the results, but since I changed themes, it looks like this now and I hate it. I also have the List Category Post plugin, but can't figure out how to make the container.

Is there any way for me to do this using the plugins I have or with code. I'm new to coding, but I'm willing to try anything to make this work. Thank you!

My website: http://www.GigaGeekMagazine.com

rebelyun on "php help"

$
0
0

Hello, can anyone assist me with this code?

I'm trying to modify it so that when a post is labeled under a certain category, it will remove the timestamp and author.

<?php get_header(); ?>
	<div id="single_cont">

		<div class="single_left">

			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
				<h1 class="single_title"><?php the_title(); ?></h1>
<?php the_time('m/j/y'); ?> at <?php the_time('G:i'); ?> by <?php the_author() ?>
				<div class="single_inside_content">
				<?php the_content(); ?>
				</div><!--//single_inside_content-->
				<br /><br />
				<?php comments_template(); ?>
			<?php endwhile; else: ?>
				<h3>Sorry, no posts matched your criteria.</h3>
			<?php endif; ?>                    

		</div><!--//single_left-->

		<?php get_sidebar(); ?>

		<div class="clear"></div>

	</div><!--//single_cont-->

<?php get_footer(); ?>

Reglitch on "the_excerpt Not Working"

$
0
0

I'm editing a page to display new posts instead of pages, so far so good. The only thing that hasn't translated over to the posts is the return from the_excerpt(). In fact, everything else is returned fine. This is really confusing me, so I would love it if someone could take a look at this code as it's beginning to grate on me. As far as I can tell, it is within "the loop."

Here's a link to the code.

Here's
a picture of the annoyance, it's even cheeky enough to bring back the read more link.

wilkyboy2 on "Custom Wordpress author names"

$
0
0

Hi All,

I am migrating my school's Online Newspaper from Joomla to Wordpress, and I am trying to modify the theme (Twenty Fourteen), so that it uses a metadata key value as the display name for a post (since most of the content creators have had their posts submitted to the old site using an editor as a proxy, so their names are stored as 'author aliases').
It should be as simple as:

if (author_id = 0) {
    $author_name = $meta['alias'];
}

My awesome php simplification
But where should this be implemented within the vast expanse of wordpress code.

I would also greatly appreciate being shown how to configure all of the other author related perks (list author posts, these authors have contributed etc.)

I would show you the site in situ, but unfortunately it is running on my local dev machine. Not that seeing it would help at all.

any help at all would be greatly appreciated!

-- Wilky

punith21 on "To fetch the form results from an external website and displaying on my site"

$
0
0

hi
i'm new to php but i tried to make my own edu website but i'm facing lot of problem bu using php
when the students enter their usn no(eg:1db12cs005) when user hit submit button it must fetch result from external website(eg:http://www.results.vtu.ac.in/)‎ but I don't want to redirected to the external website, where results can be seen. Instead, I want the results to be displayed on the same website. I'm open to to all kinds of suggestion!
i'm new to php so plz help me by giving complete code

i got this from some website but it's not working properly.when the student enter their usn no and when they hit submit button its just accessing their name but its not showing their marks and also it's showing its result in sidebar i want to display in new windows(their r many website for eg fastvturesults.com,vtualerts they fetch from website http://www.results.vtu.ac.in/ )

<?php

echo '<form action="' . $_SERVER[PHP_SELF] . '" method="post">
<input type="text" name="rid">
<input type="submit" name="submit" value="submit">
</form>';

if(isset($_POST['submit'])&&(!empty($_POST['rid'])))
{
    $location = 'http://results.vtu.ac.in/vitavi.php';

    $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $location );

    $post_array = array(
        "rid" => $_POST['rid'],
        "submit" => "submit"
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
    $response = curl_exec($ch);

    $start = '<TD width="513">';
    $end = '<br>';

    $response = strstr($response, $start);
    $end = stripos($response, $end);
    $response = substr($response, strlen($start), $end - strlen($start));

    echo $response."<br/>";
}  

?>

Tom Sketch on "Custom Post Meta not displaying when web site moved"

$
0
0

Hi there,

This is the first time I've posted in the WordPress forum. I've used wordpress for a while now and have recently ventured into creating my own custom post types and custom meta so I can have more control and not have to rely so heavily on plugins.

I've managed to set up some custom post meta which has been working fine in my local environment. The idea is the user can add more than one meta box called "slides" and add data to each slide.

The problem occurred when I moved my site to a test server to start adding content etc. The custom post meta still works as expected however the content I added in the local environment will not display. It is in the database but will not come through. Any data I put in to the 'slides' overwrites the old content and then works as expected.

I need to sort this now otherwise when it come to going live I will have a lot of content to add in all over again, losing about 3 days of work!

Here are the main highlights of the code.

add_meta_box (fairly standard):

function dynamic_add_custom_box() {
    add_meta_box('slide_content', __( 'Scrolling Page', 'scrolling_pages' ), 'slide_content_custom_box');
}
add_action( 'add_meta_boxes', 'dynamic_add_custom_box' );

The main function to pull the data into the page editor (slightly simplified!):

function slide_content_custom_box() {
    global $post;
    wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );

    ?>
    <div id="meta_inner">
    <?php

    $slide_content = get_post_meta($post->ID,'slide_content',true);
    $c = 0;
        foreach( $slide_content as $content ) {
            if ( isset( $content['image'] ) || isset( $content['text'] ) ) {

				echo '<div class="slide"><h2>' . ($c+1) . '. ' . $content['title'] . '</h2><a class="sort">|||</a>
				<div class="slideContent">
				<label for="meta-title" class="prfx-row-title">Slide Title</label>
			<span class="inputWrap">
			<input type="text" name="slide_content[' . $c . '][title]" class="text_multiple_title' . $c . '" value="' . $content['title'] . '" />
			</span>
			</div></div>';
                $c = $c +1;
            }
    }
    ?>
<span id="here"></span>
<span class="add"><?php _e('Add Slide'); ?></span>
<script type="text/javascript">
 var $ =jQuery.noConflict();
 $(document).ready(function() {
	$('.slideContent').hide();
 	var count = <?php echo $c; ?>;
    $(".add").click(function() {
	slide = count + 2;
        $('#here').append('<div class="slide"><h2>' . ($c+1) . '. ' . $content['title'] . '</h2><a class="sort">|||</a><div class="slideContent"><label for="meta-title" class="prfx-row-title">Slide Title</label><span class="inputWrap"><input type="text" name="slide_content[' . $c . '][title]" class="text_multiple_title' . $c . '" value="' . $content['title'] . '" /></span></div></div>' );
		count++;
        return false;
     });
     $(".remove").live('click', function() {
        $(this).closest('.slide').remove();
     });
});
</script>
</div>
<?php
}

Saving the data:

function dynamic_save_postdata( $post_id ) {
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
        return;
    if ( !isset( $_POST['dynamicMeta_noncename'] ) )
        return;
    if ( !wp_verify_nonce( $_POST['dynamicMeta_noncename'], plugin_basename( __FILE__ ) ) )
        return;
    $slide_content = $_POST['slide_content'];
	if ($slide_content != "") {
    	update_post_meta($post_id,'slide_content',$slide_content);
	}
}

I've been banging my head against a brick wall for a few hours now. Could it be something to do with the Nonce?

Any help would be appreciated.

inspiredwp2013 on "get the title from current loop of flexslider"

$
0
0

Hi i have this code of flexslider written in featureflexslider.php

<?php
   // Get all sticky posts, but only sticky posts
   $sticky = get_option( 'sticky_posts' );
   $args = array(
        'numberposts' => 6, // Display up to 6 posts. Change at will
        'post__in'  => $sticky
         );
	$postQuery = get_posts($args);
        foreach( $postQuery as $post ) : setup_postdata($post);

          if ( has_post_thumbnail() ) { ?>
	    <li>
		<a href="<?php echo get_permalink(); ?>" title="Go to <?           php echo the_title(); ?>" rel="bookmark">
	       <?php the_post_thumbnail('feature-slider'); ?>
		<p class="flex-caption"><?php the_title(); ?></p>

		</a>
	    </li>

    <?php}
	endforeach; ?>

now i want the current title of the flexslider to appear outside the <ul class='slides'> but i don't know how to do it. this is my code in my header.php file

<div id="featured_posts">
  <div class="flexslider">
    <ul class="slides">

	<?php get_template_part( 'featureflexslider' ); ?>
   </ul>
  </div>
    <?php //I WANT THE CURRENT POST TITLE TO APPEAR HERE ?>
</div>

jwiere03 on "What hook to use for css?"

$
0
0

I have made a simple plugin that includes some css that styles the front end. I'm calling the function that includes the css with the get_header hook. It works fine. But I was just wondering if this was the best hook to use for this?

I've only made a couple of other plugins before and I'm not 100% sure on all the hooks.

Thanks

robinalexander on "User post.php for my plugins"

$
0
0

I recently read through the basic tutorial for plug-in coding at Wordpress Codex. I don't recall reading anything about how I use post.php for my plugin to make posts. If I eg. want to start coding a e-store solution, that would be a great resource. So, can someone just pass me through to a good tutorial for that? Thanks.

bastien31 on "CSV import and post automatic creation"

$
0
0

Hi,

As part of the redesign of a car garage website in Wordpress, my client would like to display a list of vehicles contained in a csv file he receives each week. So every week, I must update the list presented on the site by adding new vehicles and removing sold vehicles.

I have good PHP / MySQL knowledge but I 've never done custom code like this in Wordpress. I wanted a few tracks or confirmation regarding the implementation of a solution.

That's what I think to make:

- a PHP function to parse the CSV file in order to extract each entry (vehicle)

- a function (a plugin for example) which call the parser function. For each entry, it checks if it exists in the Wordpress DB. If not, I insert the entry with a insert_custom_post. I keep all the id in order at the end to be able to do the reverse to remove the sold vehicles.

Where I don't exactly know what to do, is what type of post to use. I want to be able to perform research on these posts (vehicles type) kie brand, year, kilometers or price.

I think I have to create a custom post type (maybe two ? one for the global list, one for the detailed vehicle ?).

Is anybody can tell me more about this king of development ?

Thanks a lot
Nice day,

Bastien

Viewing all 8245 articles
Browse latest View live




Latest Images