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

bradklosterman on "add_user_page (profile sub menu) with meta fields input"

$
0
0

Create multiple user_page (sub-page for profile menu page on the administration screen) on the admin_menu of an author. The function of each each page displays a screen that has user meta input fields and save button. The data needs placed in a pdf ready for print. This is what I have. I need to place user meta fields in each page. Any suggestions would be greatly appreciated.

add_action('admin_menu', 'my_users_menu');

function my_users_menu() {
add_users_page(__('Education and Qualifications ','userinfo2'), __('Education and Qualifications','userinfo2'), 'read', 'userinfo2', 'userinfo2');
add_users_page('Voluntary Experience', 'Voluntary Experience', 'read', 'userinfo3', 'userinfo3');
}

function userinfo2() {
if ( !current_user_can( 'read' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrapfile">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}

function userinfo3() {
if ( !current_user_can( 'read' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrapfile">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}


creativexplore on "Replacing widget titles with images."

$
0
0

Hello,

I'm trying to replace the titles of several of my widgets (i.e. archives, categories, social icons) with images. Right now I have removed the title and placed the image on top of the widget, but I would like to be able to make the title the image so that I can place a single border around the entire thing (both title and widget). You can probably see what I'm talking about on my blog.Currently there are separate borders around the image titles and the widget. Also, is there a way to do this using the Custom CSS Plugin as opposed to going straight into the files?

I've tried several of the solutions that are already on this forum, but none of them seem to work - probably because my theme is different (Estelle by Bluchic). Can anybody help me out?

insonetfbi on "images no longer display in my site"

$
0
0

all my plugins are in the latest version, am also using a jetpack. but now all my images are not showing, i have contacted my service host and evrything is just fine.
here is my website http://naijagood.com
i wonder if its a plugin that is causing it.
please help me

Kevin on "Trouble querying term meta via REGEXP"

$
0
0

So I am having trouble querying specific taxonomy terms based on regex values. Here is what I am trying to do.

I have a custom taxonomy called issue assigned a term meta labeled meta_issue_published_date. The meta is stored in the db in the format 'yyymmdd'. Looking at the table in the db all of the issues and their published dates are being saved correctly.

Now on the frontend I am converting the dates to 'Y' format and allowing users to select a year. Here is an example of the function I am using:

/**
 * Get the year from date field
 */
function namespace_get_the_year( $issue ) {
  $date = get_term_meta( $issue->term_id, 'meta_issue_published_date', $issue );
  $year = date( 'Y', strtotime( $date ) );
  return $year;
}

This is working fine. However, I am trying to run a query once a user selects a year and find all issues whose meta_issue_published_date begins with the year they selected. For instance, if a user selects '2015', I want to query all issues whose meta_issue_published_date beings with 2015. Here is how I am trying to accomplish this:

// $date is determined by users choice and is returning the correct value

// Get all issues belonging to the year
$args = array(
	'key'	=> 'meta_issue_published_date',
	'value'	=> '^(' . $date . ')',
	'compare'	=> 'REGEXP'
);
$issues = get_terms( 'issue', $args );

However, this isn't doing at all what I would like and I don't know what exactly is going on. Running a test when selecting '2015', here is what the meta_query arguments look like, followed by the meta_issue_published_date values of each returned issue:

Array
(
    [key] => meta_issue_published_date
    [value] => ^(2015)
    [compare] => REGEXP
)
20141202
20141201
20150601

There are other meta_issue_published_date values in the db other than the ones returned, so I'm not sure what exactly might be going on here. I'm not proficient in REGEX, so I am assuming I'm going something wrong for the value key in my arguments.

A little wisdom would be appreciated...

sharkonda on "Use Custom Fields as thumbnails"

$
0
0

Hi, I'm using SimplePress theme with an epanel slider.
I'm not very proficient with PHP, so I hope someone can point me in the right direction: The site is thebellevuelocksmith.com and as you can see, the thumbs under the slider are generated with print_thumbnail and are the same as the slider images - what I want to do is call on each page's Custom Field named 'Thumbnail' which contains an url to the custom icon i would like displayed for each slider.
Here's the current code for the lower area:

<?php for ($i = 1; $i <= $featured_num; $i++) { ?>
       	  <div class="item">
              <div class="wrap <?php if($i == 1) echo('active'); ?>">
               	  <span class="image" style="background-image: url(<?php print_thumbnail($arr[$i]["thumb_small"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"], $width_small, $height_small, '', true, true); ?>);"><img src="<?php bloginfo('template_directory'); ?>/images/slider-thumb-overlay.png" alt="" /></span>
                  <div class="hover">
                      <span><?php echo esc_html($arr[$i]["fulltitle"]); ?></span>
                      <br class="clear" />
                      <?php echo($arr[$i]["excerpt_small"]); ?>
                  </div>
              </div>
          </div>
          <?php }; ?>

Hope someone can help, thanks in advance.

linuxjackie on "How to fully disable 'Edit Image' function ?"

$
0
0

How to fully disable 'Edit Image' function ?
or only available for admin .

Thank You
Jackie

FlintStoned- on "Adding 'text' after blogpost content for specific category using functions.php"

$
0
0

Hi all WordPress members,

I'm trying to add text (call to action button) after my blogposts. This worked because I only used 1 category. Now I have two. So, I want to disable it on my other category or add some other 'text'.

The code I think would work,.. (but does not)(functions.php)

add_filter('the_content', 'add_my_content');
function add_my_content($content) {
$my_custom_text = 'The text you want to display,..';
if(is_single() && !is_home() && is_category('1')) {
$content .= $my_custom_text;
}
return $content;
}

It works without && is_category('1')

Can someone help me to display only this text for my category with id 1 (or any other id) and not on the other categories?

Kind regards,
Flint.

vespino on "Add category to custom post type"

$
0
0

I have registered a CPT called "optredens" and I'm planning on importing a XML file. During the import I would like to check if a certain category (a field from the XML) within the CPT exists. If not, create it.

The following doesn't do anything:

if(!term_exists( 'testest', 'optredens') ){
	wp_insert_term( 'testest', 'optredens' );
}

Can anybody tell me how this is done?


Arevico on "WP_List_Table Documentation vs Practice"

$
0
0

Hey,

I've a question regarding WP_List_Table

I found that the following notice is listed:
NOTICE: As of WordPress 3.5.1, in core $item is passed an Object, not an array.

However, when I test it out in my code, it seems like $items is still passed as an array in the latest WordPress.

/**
     * Retrieve the data associated with a specific column.
     * @param array $item The row
     * @param string $column_name The index of the column (internal name)
     */
    function column_default($item, $column_name){
        var_dump($item);
        switch ($column_name) {

            case 'when':
                return isset($item['when']) ? date('Y-m-d h:i:s' ,trim( $item['when']) ) : '-';
                break;

            default:
                return isset($item[$column_name]) ? htmlentities($item[$column_name]) : '';
                break;
        }

    }

I also checked the source and the phpDoc also lists an object instead of an array, but var_dumping results in an array.

Is the documentation correct or is this a bug or did I misunderstand it? If anyone knows, please let me know :)

Glenn on "plugin php error "Warning: Creating default object in...""

$
0
0

A plugin I have (wp-veriteco-timeline) is causing this error when I hit Publish on its Custom Post Type BUT it IS saving the Featured Image and content.

"Warning: Creating default object from empty value in /.../wp-content/plugins/wp-veriteco-timeline/wp-veriteco-timeline.php on line 60"

"Warning: Cannot modify header information - headers already sent by (output started at /.../wp-content/plugins/wp-veriteco-timeline/wp-veriteco-timeline.php:60) in /.../wp-admin/post.php on line 197"

Anyone see anything wrong with this code as regards WP?

$thumbnail_id = get_post_thumbnail_id( $this->post_id );

			if( $thumbnail_id ) {
				// if there is featured image
				$img = wp_get_attachment_image_src( $thumbnail_id, 'full' );
				$thumbnail_image = get_post( $thumbnail_id, 'OBJECT' );
				if ($thumbnail_image && isset($thumbnail_image)) {
					$this->asset->media = $img[0];
					$this->asset->caption = $thumbnail_image->post_excerpt;
				}
			} else if( $meta['wpvt_video'][0] ) {
				// otherwise, look for youtube link
				$this->asset->media = $meta['wpvt_video'][0];
				$this->asset->caption = $meta['wpvt_video_caption'][0];
			}

Thanks for anyone's help.

GN

drking on "How to deliver a generated pdf to the browser from a plugin"

$
0
0

I have a custom plugin, where I want a user to be able to click on a link to obtain a pdf created by the plugin on the fly. FPDF does this well on a standalone test site, but I cannot find a good way to implement this within Wordpress. Options:
1. The link calls a js function which gets the pdf from the server via AJAX (but how to get the AJAX output to the user? I think this can't work, but can't find a spec for what happens with what say onclick() returns)
2. Call a page and get the plugin to intercept absolutely all WP's output including HTTP headers - but what's the correct hook/method to do this?
3. Generate the pdf file from a previous request, store it in a uniquely named folder and delete the folder after a period. This would work, but it's slow, messy and a workaround, not a solution. And I'm not sure where these folders should be stored.
4. Other ideas?

There are various existing plugins that allow the user to click a button and get a pdf of the page/post; the only one of these that I've been able to decipher stores the generated pdf file on a remote server, which is not an option for me. But it is clearly possible to deliver a generated pdf - I must be misunderstanding something.

This thread:
https://wordpress.org/support/topic/how-to-use-fpdf-force-download-in-custom-plugin-to-force-pdf-download?replies=2
lists some of the approaches tried by someone else in a similar but not identical situation.

I hope you'll be able to enlighten me - thank you

Mustafa 007 on "Selecting custom data from wordpress db to android app"

$
0
0

I am developing an Android application which is needed to retrieve custom data from WordPress DB. From my own Web App, I am receiving posts in 3 below steps:
1- The Mobile application sends request containing the required post ID to the web app.
2- Web app, executes query where id is equal to requested ID.
3- Web app parses selected data to JSON format and response the JSON file back to Mobile Application.

Now, I need to receive such a data from WordPress DB. Please let me know if you know any solution.
Thanks.

grafixNZ on "Remove text-transform from forms"

$
0
0

Hello,

The theme I am using had all the text in the forms capitalized. I have removed it from the checkout forms with this css

.woocommerce-billing-fields input {
text-transform: none !important;
}

but I still have the issue with the login/registration form and the Address input forms on the "my Account" page.

I couldn't figure out what to use, can anyone suggest something?

website: http://www.wholesalehemp.co.nz

Many thanks

jsjs on "WordPress add_rewrite_rule problems when rewriting to startpage"

$
0
0

Hi,

I do a custom wordpress rewrite with the following code:

function add_rewrite_rules() {
    	add_rewrite_rule(
      		'^mypath/([A-z0-9\-\_\,]+)/?$',
      		'index.php?page_id=2&tags=$matches[0]',
      		'top'
      	);
    }
    add_action('init', 'add_rewrite_rules');

This works fine:
When I open /mypath/tag1,tag2,tag3/ the page with the page_id==2 is shown, and GET parameter tags contains tag1,tag2,tag3.
The path stays /mypath/tag1,tag2,tag3/

But there is one exception: When the page with the page_id==2 is marked as the wordpress startpage, then he forgets everything and redirects to /

Wordpress seems to redirect to WP_HOME, if the page is the startpage, but I want it to stay on /mypath/tag1,tag2,tag3/, because I want to load my startpage and use the tags parameter in an angular script.

Does somebody have an idea how I can prevent this redirect?

linuxjackie on "How to physically rename 'wp-admin' ?"

$
0
0

How to physically rename 'wp-admin' ?
for e.g. wp-admin -> admin .
not the .htaccess , function.php one

Thank You !
Jackie


Guido on "Sanitize and escape when value is static"

$
0
0

Hi,

Is it absolutely necessary to sanitize on input and escape on output in case of a static value?

For example, saving yes/no value of a checkbox in database:

if ( isset( $_POST['checkbox-name'] ) ) {
	update_post_meta( $post_id, 'checkbox-var', 'yes' );
} else {
	update_post_meta( $post_id, 'checkbox-var', 'no' );
}

And display a static value in frontend:

if ($checkbox-var == 'yes') {
	$value = 'like';
} else {
	$value = 'don't like';
}
<?php echo "Hello there, I $value green tea."; ?>

I'm just wondering why..

Guido

amolnar on "Menu Bar text was automatically changed and goes to 404 error page"

$
0
0

The menu bar text has automatically changed to show new pages that I haven't created!
The "new pages" are -
Student thesis writing
Goldie Hawn Essay Writing
Research papers in English
Research papers for cheap...
....and so on. We are a travel company! The "new pages" that when clicked go to a 404 error page do not appear in my page listing nor do they appear on any other pages when I try to replicate it. I refresh the page and I get different "new page" links.

I have screenshots that I can share as well. Since this is not showing up on other pages I am not sure if it is a page error or if the site has been hacked, I have no idea how to proceed. Thanks in advance.

skwerlzu on "Ajax $current_user info returning false"

$
0
0

I have an ajax login function that worked locally, but now that it's on a live server it returns false for any user information.

for example. I am sending back an array to the device with something like
[["TRUE",1,"username","user@email.com"]]

when posting via ajax I get the following returned.
[["TRUE",0,false,false]]

I have tried various methods of POST and GET to no avail. As I said, the code as is worked locally, but not on a remote server. I was considering a cross domain issue, but I test with cordova which inherently has crossdomain enabled as well as a modified developer version of google chrome that allows cross domain.

I have inserted the code below. Any help would be greatly appreciated.

PHP
function already_logged_in()

{

	global $current_user;
      get_currentuserinfo();

	$creds = array();

	$auth_resp = "TRUE";

	$creds_id = $current_user->ID;

	$img_url_temp = $current_user->ID;

	$creds_login = $current_user->user_login;

	$creds_pass = 'correct';

	$creds_email = $current_user->user_email;

	$creds_role = $current_user->user_level;

	$creds_fname = $current_user->user_firstname;

	$creds_lname = $current_user->user_lastname;

	$creds_dispname = $current_user->display_name;

	$creds_imgurl = get_av_url($creds_id);

	$creds_coverurl = get_cover_url($creds_id);

	$creds_array = array($auth_resp,$creds_id,$creds_login,$creds_pass,$creds_email,$creds_role,$creds_fname,$creds_lname,$creds_dispname,$creds_imgurl,$creds_coverurl);

header("Content-Type: application/json");

	array_push($creds, $creds_array);

	echo json_encode($creds);

	die();

}

function login()

{

	header("Content-Type: application/json");

	$creds = array();

	$creds_fail = array();

	$creds['user_login'] = $_GET["username"];

	$creds['user_password'] = $_GET["password"];

	$user_stat = wp_signon($creds, false);

	if (is_wp_error($user_stat))

	{

	$auth_resp = "FALSE";

	$creds_array = array($auth_resp,"0","0","0","0","0","0","0","0");

	array_push($creds_fail, $creds_array);

		echo json_encode($creds_fail);

		die();

	}else{

	already_logged_in();

	}

}

JQUERY

function login()
{
    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;

    if(username == "")
    {
        alert("Please enter username", null, "Username Missing", "OK");
        return;
    }

    if(password == "")
    {
        alert("Please enter password", null, "Password Missing", "OK");
        return;
    }

    $('#login_loader').css('display', 'block');
    $('#login_loader').fadeTo('fast', 1, function () {
        // Animation complete.
    });
    $('#login_form').css('display', 'none');

    var xhr = new XMLHttpRequest();
    xhr.open("GET", ajaxurl + "?action=login&username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password));
    xhr.onload = function(){

		var creds = [];
		var user_info_storage = "";
		var log = "";
		var id = "";

		var login_array = JSON.parse(xhr.responseText);
		var creds_login = "";
		var creds_pass = "";
		var creds_email = "";
		var creds_role = "";
		var creds_fname = "";
		var creds_lname = "";
		var creds_dispname = "";
		var creds_imgurl = "";
		var creds_coverurl = "";

		for(var count = 0; count < login_array.length; count++)
        {
            log = login_array[count][0];
            id = login_array[count][1];
            creds_login = login_array[count][2];
            creds_pass = login_array[count][3];
			creds_email = login_array[count][4];
			creds_role = login_array[count][5];
			creds_fname = login_array[count][6];
			creds_lname = login_array[count][7];
			creds_dispname = login_array[count][8];
			creds_imgurl = login_array[count][9];
			creds_coverurl = login_array[count][10];

		}

		creds.push(log);
		creds.push(id);
		creds.push(creds_login);
		creds.push(password);
		creds.push(creds_email);
		creds.push(creds_role);
		creds.push(creds_fname);
		creds.push(creds_lname);
		creds.push(creds_dispname);
		creds.push(creds_imgurl);
		creds.push(creds_coverurl);

        if(log == "FALSE")
        {
            // alert("Wrong Username and Password", null, "Wrong Creds", "Try Again");
            myApp.addNotification({
                title: 'Login Error',
                subtitle: '',
                message: 'Wrong login or password',
                media: '<i class="trekicons trek-trekfind"></i>'
            });
            $('#login_loader').css('display', 'none');
            $('#login_form').fadeTo('fast', 1, function () {
                // Animation complete.
            });
        }
        else if(log == "TRUE")
        {
			if(id == 0){
				//alert("Incorrect feedback");
				window.setTimeout(login, 1000);
			} else {

            //fetch_and_display_posts();
            //$("#page_two_link").click();
			//$("#testing").html(creds);

			    window.localStorage.setItem("user.info", JSON.stringify([creds]));
			    $('#user_disp_name').html(creds_dispname);
			$('#login_loader').css('display', 'none');
			//$('#login_form').fadeTo('fast', 1, function () {
			    // Animation complete.
			//});
			myApp.closeModal('.popup-login');
			user_check();
			}
        }
    }
    xhr.send();
}

squirtlesquirt on "Custom post type URL"

$
0
0

Does anyone know what causes Wordpress URL redirects to work when entering only one letter?

For some reason if I enter the following:
website.com/r
it will redirect to website.com/shoes/heels/red-shoe
Has anyone seen that before? What is causing this?

I have 2 custom taxonomies and 1 custom post type.
My custom post type has rewrite rules in it like so:

'rewrite' => array(
'slug' => '%category_tags%/%topic_tags%',
'with_front' => false,
),
So a url looks like website.com/shoes/heels/red-shoe

technodestructo on "Custom Post Types and Categories"

$
0
0

Hello,

I have a custom theme which allows me to set up properties and using a template within the theme, it takes all those properties and puts them on one page. Now I am trying to have it send the types of property to 2 different pages, one for sale and the other sold. I have set up Post Types and Categories. I have made pages just for the categories and custom post types. All I get is 404. Any help would be appreciated.

Viewing all 8245 articles
Browse latest View live




Latest Images