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

tsusanka on "Add link to the admin's "New" menu"

$
0
0

Is it possible to add a link to the New menu in top left corner?

Image here

Something like the add_menu_page() and add_submenu_page() but for the New menu.


hdnminh007 on "How to have White page when go to wedsite"

$
0
0

How to have a white page when log in to wedsite?

Chris_topher on "need to find an external database's prefix"

$
0
0

I'm creating a plugin and part of the plugin requires that I connect to an external WordPress site and use that site's external database to get some information. I have established a connection and I have accessed the external database's $wpdb using the code below:

global $new_wpdb;

define( 'BLOCK_LOAD', true );
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/wp-db.php' );
$new_wpdb = new wpdb( $username, $password, $dbname, $servername);
$new_wpdb->show_errors();

When I use print_r($new_wpdb);, I get the array and I can see the values for the external database's username, password, etc. However, there's no value for prefix or base_prefix. It's just displaying the following for the prefix:

[prefix] => [base_prefix] =>
How do I get the prefix that the external database is using?

Bearsaurus on "Form that can add"

$
0
0

Hello,

Our website has over 20 products and people can choose a size, color, and quantity. This is only a form as we dont want this to be ecommerce.

I want a form that people can input their information and in the end, they can input the products that they want. There would be an add button for each product they want to order. For example, i want product 1 with yellow, large size, and 200 orders. By pressing an add button, users can add another category to select their products. They can then order product 1 again with red, small and 100 orders.

Is there a possible plugin that can do this?

cyberlp23 on "Send an email when submit to review + custom field?"

$
0
0

Hello,

I would like to be able to send an automatic email to the author of a post when their post is saved as "pending" (from a previous "pending" status) + a certain custom field ("statut_article") = 2.

I guess it should be like:

function notify_trash( $post ) {
$rejete = get_post_meta($post->ID, 'statut_article');
if ($rejete == '2') :
  $user_info = get_userdata ($post->post_author);
  $strTo = array ('webmaster@mysite.com');
  $strSubject = 'Fstoppers: ' . $user_info->user_nicename . ' submitted a post';
  $strMessage = '"' . $post->post_title . '" by ' . $user_info->user_nicename . ' was submitted a post for review at ' . 			wp_get_shortlink ($post->ID) . '&preview=true. Please proof.';
  wp_mail( $strTo, $strSubject, $strMessage );
endif;
}
add_action( 'transition_post_status', 'notify_trash', 10, 3 );

But this doesn't work... Any idea?

Thanks!

brandnucreative on "How to add custom field to wordpress register form"

$
0
0

I'm using a pre-built registration form for new users to sign up to a website. I want to be able to add two fields to the form so that users can input their first name and last name to the form, and that will then display in the user dashboard in the back-end of the website.

Heres the php code as it stands: I've added the fields to the form, but I'm getting an issue where even though first name and surname are being submitted, they aren't appearing in the user's account in the dashboard.

Thanks,
G

public static function init_fields() {
self::$fields = apply_filters( 'register_form_fields', array(
'creds' => array(
'nicename' => array(
'label' => __( 'Username', 'jobify' ),
'type' => 'text',
'required' => true,
'placeholder' => '',
'priority' => 1
),
'first_name' => array(
'label' => __( 'First Name', 'jobify' ),
'type' => 'text',
'required' => true,
'placeholder' => '',
'priority' => 2
),
'last_name' => array(
'label' => __( 'Surname', 'jobify' ),
'type' => 'text',
'required' => true,
'placeholder' => '',
'priority' => 3
),
'email' => array(
'label' => __( 'Email Address', 'jobify' ),
'type' => 'text',
'required' => true,
'placeholder' => __( 'email@example.com', 'jobify' ),
'priority' => 4
),
'password' => array(
'label' => __( 'Password', 'jobify' ),
'type' => 'password',
'required' => true,
'placeholder' => '',
'priority' => 5
)
),
'info' => array(
'role' => array(
'label' => __( 'About You', 'jobify' ),
'type' => 'select',
'required' => true,
'priority' => 6,
'options' => array(
'none' => __( '—Select—', 'jobify' ),
'employer' => __( 'I'm an employer looking to hire', 'jobify' ),
'candidate' => __( 'I'm a paralegal applying for jobs', 'jobify' )
)
)
)
) );
}

mokum on "Show links on mainpage blogposts!"

$
0
0

Hello,

I'm trying to show the links i've putt in blogposts on the mainpage. The blogs are cut off by the read more tag but links are disabled in the blog "previews" any ideas on fixing that?

ravidigi on "how to make featured image loaded through external link"

$
0
0

I have hosting my blog images on image hosting company. Post images are loaded through the image hosting but i want to load the featured image as well from the image hosting company. Please help me with this.


Bernardus Valentino on "What plugin should i use to make this"

$
0
0

Hi, my name is Bernardus and i am from Indonesia. I hope you can help me with my problem.

I am wondering at how i can make a product catalog such as this
http://apparelgaming.com/detailproduct.php?id=184
or like
http://www.icetechno.com/produk.html?id=RAZER_V3_TSHIRT
but with no "add to your cart button" or something like that just the product details.

This is due to my dropshipping business where the stock of the products is not stable at all, so i cannot guarantee my customers about the availability of the product.

Thank You.

Bearsaurus on "What plugin can make a customizable check out form?"

$
0
0

I need a check out form that looks similar to the link below.

http://2nlizv2n463m4ezbxb1ci6m1.wpengine.netdna-cdn.com/wp-content/uploads/2011/11/Screen-Shot-2013-05-23-at-13.29.09-620x321.png

As you can tell this is not a check out form but I need the elements on the bottom box(option label, option price, min,max). The most important function I need is the new option button.

I am about to create an order form for customers where they can fill in their contact information along with the product they need. The product part will be the same as the link above where they can customize their own product and add additional products as well.

Any pointers on where I can do something like this? plugins or templates?

Thanks everyone

Kevin on "Inserting portions of loops inside different functions?"

$
0
0

Just wondering about this. Is it possible to divide up portions of loops inside different functions. For instance, say I have the following code:

while( have_rows( 'content' ) ) : the_row(); if( get_row_layout() == 'cool-layout' ) :

How might I be able to accomplish something like the following:

global $content;
$content = 'content';

function begin_layout( $name ) {
  while( have_rows( $content ) ) : the_row(); if( get_row_layout() == $name ) :
}
function end_layout() {
  endif; endwhile;
}

Then in my templates simply initialize and close the layouts with the following:

begin_layout(cool-layout);

  // Content

end_layout();

Obviously the functions I made up don't work, but I was wondering how I might be able to accomplish the same logic?

LPD7Pkmxe6 on "Coding : How to change post_format value"

$
0
0

Hi,

I'm trying to figure out what I'm doing wrong in the attached coding example.

I can successfully post to wordpress, but I can't figure out how to change the post_format value to "link" successfully. No matter what I have tried, the post_format value is set to 'standard'. I need it set to 'link' and also be able to designate a URL. I've spent lots of time looking at posts on the internet with no luck. I'm missing 'something'.

The php file for testing resides in the root directory of my wordpress installation.

<?php
//figure out how to add a post with link format and URL

error_reporting(-1);
$location = $_SERVER['DOCUMENT_ROOT'];

echo $location;
//exit;
include ($location . '/wp-config.php');
include ($location . '/wp-load.php');
include ($location . '/wp-includes/pluggable.php');
//include_once($location.'/wp-includes/post-formats.php');

require($location . '/wp-blog-header.php');
// Create post object
$my_post = array();
$my_post['post_title'] = 'Title of this Post';
$my_post['post_content'] = 'Some Content to Add';
$my_post['post_status'] = 'publish';
$my_post['post_type']= 'post';
//post_category is correct here
$my_post['post_category'] = array(34);
//post_format always goes to 'standard'
//tried array(2) also with no luck
$my_post['post_format']='link';

//very array
print_r ($my_post);

//all the below commented options were tried with no success.
//set_post_format('', 'link' ); //sets the given post to the 'link' format
//set_post_format($mypost->'ID', 'link' ); //sets the given post to the 'link' format
//$my_post['post_link_url'] = "http://www.SomeTestUrl.com";
//$my_post['post_link'] = "http://www.SomeTestUrl.net";

// Insert the post into the database
if( null == get_page_by_title( $my_post['post_title'] ) ) {
wp_insert_post( $my_post );
}

//Post is successfully added but can't change post_format value to 'link'

?>

jeremyjmccourt on "Getting value out of meta_value from the wp_postmeta table"

$
0
0

Hello, I am trying to grab a certain value from the meta_value column in the Wordpress database. I have created my own php file to grab the meta_value column and it returns data like this:

"a:19:{s:10:"dataformat";s:3:"mp3";s:8:"channels";i:2;s:11:"sample_rate";i:44100;s:7:"bitrate";d:128009.140406539037940092384815216064453125;s:11:"channelmode";s:6:"stereo";s:12:"bitrate_mode";s:3:"vbr";s:8:"lossless";b:0;s:15:"encoder_options";s:3:"VBR";s:17:"compression_ratio";d:0.09070942489125498331414831909569329582154750823974609375;s:10:"fileformat";s:3:"mp3";s:8:"filesize";i:5829850;s:9:"mime_type";s:10:"audio/mpeg";s:6:"length";i:364;s:16:"length_formatted";s:4:"6:04";s:4:"text";s:4:"dash";s:13:"encoding_time";s:19:"2014-01-25 18:12:43";s:16:"encoder_settings";s:11:"Lavf54.20.4";s:6:"artist";s:0:"";s:5:"album";s:3:"Fly";}"

I need to be able to get the album value does anyone know how?

My php currently looks like:

$st = $db->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_value LIKE '%album%'");

$st->execute();
$obj = $st->fetchAll();
echo json_encode($obj);

eclev91 on "Expanding the media library select options"

$
0
0

I'm trying to add an option to the media library select dropdown that will allow the user to view only images uploaded by a particular author - I don't want this to definitively be the case, I want the option via the select box.

Right now I've overridden AttachmentFilters.All's createFilters function to add my own filter like so:

add_action( 'admin_print_footer_scripts', 'add_author_to_filter_object', 51);

function add_author_to_filter_object() { ?>
	    <script type="text/javascript">
	    // Add custom post type filters
	    l10n = wp.media.view.l10n = typeof _wpMediaViewsL10n === 'undefined' ? {} : _wpMediaViewsL10n;
	    wp.media.view.AttachmentFilters.All.prototype.createFilters = function() {
				var filters = {};

				//new one
				filters.featuredAuthor = {
					text: 'Images Uploaded By Featured Author',
					props: {
							status:  null,
							type:    null,
							uploadedTo: null,
							orderby: 'date',
							order:   'DESC',
							featuredAuthor: true
					},
					priority: 5
				};

				_.each( wp.media.view.settings.mimeTypes || {}, function( text, key ) {
					filters[ key ] = {
						text: text,
						props: {
							status:  null,
							type:    key,
							uploadedTo: null,
							orderby: 'date',
							order:   'DESC'
						}
					};
				});

				filters.all = {
					text:  l10n.allMediaItems,
					props: {
						status:  null,
						type:    null,
						uploadedTo: null,
						orderby: 'date',
						order:   'DESC'
					},
					priority: 10
				};

				if ( wp.media.view.settings.post.id ) {
					filters.uploaded = {
						text:  l10n.uploadedToThisPost,
						props: {
							status:  null,
							type:    null,
							uploadedTo: wp.media.view.settings.post.id,
							orderby: 'menuOrder',
							order:   'ASC'
						},
						priority: 20
					};
				}

				filters.unattached = {
					text:  l10n.unattached,
					props: {
						status:     null,
						uploadedTo: 0,
						type:       null,
						orderby:    'menuOrder',
						order:      'ASC'
					},
					priority: 50
				};

				if ( wp.media.view.settings.mediaTrash &&
					this.controller.isModeActive( 'grid' ) ) {

					filters.trash = {
						text:  l10n.trash,
						props: {
							uploadedTo: null,
							status:     'trash',
							type:       null,
							orderby:    'date',
							order:      'DESC'
						},
						priority: 50
					};
				}

				this.filters = filters;
			};
	    </script>
	<?php }

Which adds the option to the select box as expected - great. Now I want to catch the ajax query and adjust its parameters accordingly:

add_filter('ajax_query_attachments_args', 'featured_author_media_filter');

public static function featured_author_media_filter($query) {
	    if($query['featuredAuthor']) {
		    $featured_author = get_field('featured_author', 2); //get from front page
		    $query['author'] = $featured_author->post_author;
		}
	    return $query;
	}

This is where things go poorly. It seems like my if statement there is never true. If I do a dump or something before it, the ajax loading of the media library fails, so I know at least my filter is being called. Is there something I'm missing? I don't feel like this whole thing is very well documented and I admittedly know next-to-nothing about Backbone.

ZakEzz on "Redirecting back to te same page after registration"

$
0
0

Hi,

I hope you will be fine and doing good. I place TML registration widget on checkout page and i want my users to auto login and redirect back to the referral page (They were visiting before registration) after registration. Currently user redirect to the login page after registration.

I was trying this code :

<?php
function tml_new_user_registered( $user_id ) {
	wp_set_auth_cookie( $user_id, false, is_ssl() );
	wp_redirect( wp_get_referer() );
	exit;
}
add_action( 'tml_new_user_registered', 'tml_new_user_registered' );

function tml_register_form() {
	wp_original_referer_field( true, 'previous' );
}
add_action( 'register_form', 'tml_register_form' );
?>

Reference : https://wordpress.org/support/topic/auto-login-after-register-and-redirect-to-profile-page?replies=44

I create a new theme-my-login-custom.php file and place it plugins/theme-my-login but it didn't work.

Please suggest a solution to make it work.


hamstair_toilichte on "Custom relational database in a Wordpress installation"

$
0
0

Hello all

This isn't so much a 'how to', as a request to be pointed to roads to go down to get to my destination. In brief, my query is: how can I create a relational database in the WP database, and use forms to populate and query it?

In more detail:

I'm after creating a links 'repository' for subjects (eg healthcare, languages), which would be a multi-table relational database. For instance, I developed the Global Health repository as a custom web app, using PHP, MySQL and Codeigniter at the back end. Contributors add a web resource by URL, name, keywords, topic and a few other criteria, and this data goes into a MySQL database with around ten tables, linked by foreign keys or junction tables.

What I'd like to do is write a plugin to enable such a repository in Wordpress. An example of a repo I'd like to transfer into WP is a healthcare resources database. I'd like to do this for the plugin writing exercise, to contribute a little back to the community, and to provide a simple tool for the user to create their own link repo in whatever subject they want. The end user should be able to search/browse for resources in that subject via a simple form.

So I may want to add custom tables to the WP database and relate them as I want. I'm not sure, though, about the best way of approaching this. I'm thinking that I could maybe use the excellent Advanced Custom Fields plugin with some Custom Post Types, and use the dbDelta() function to create tables on plugin activation as advised in this article.

Alternatively, perhaps I shouldn't mess about with the WP database, but rather create a separate DB and run queries on that from within WP.

There could be a number of roads to go down, but I'd prefer to avoid those that may lead to dead ends, hence this rather fluffy query to the WP community. How would youse go about doing this sort of thing? Am I duplicating the work of an existing plugin? (I did search the plugin repo under various keywords but got 00s of hits.) Am I barking up the wrong tree completely?

If this post should go into the Plugins forum, let me know and I'll repost it there.

HMoosy on "Create "credits""

$
0
0

Hi guys,
My website offers a "matching" service. Meaning it will link a buyer to a seller. The problem is, instead of charging a fee for the service, I would like to create "credits" or my own personnal currency that you buy to access the servie. Think of Badoo's credits system.

Basically, you buy the credits and then eveytime you want to get matched, you pay with X number of credits.

How can I set this up?

Thank you!

as9934 on "Implement non-PHP MySQL database into WordPress website?"

$
0
0

My dad runs a small internet service company and would like to redesign his website. I told him I could redesign it in WordPress because I have some knowledge of wordpress from running the website for my school's newspaper. The big problem is we can't start the creation of the website until we find a way to implement his existing Python and Paearl based MySQL database running on linux of customers into the site. I have absolutely zero knowledge of this subject so I'm turning to you guys (the experts) for advice. So...

1. How do we integrate the database into the website? Is there a plugin we can use? Can we build it into a embed code and just put it on a page?

2. Is there a specific theme or theme type we should use to design the site around this database?

3. Can we even use this database? My dad has thought about migrating it to QuickBooks Online; Would that be a better platform to build into the site?

4. How long will this take to implement?

admiralchip on "How to use FPDF force download in custom plugin to force pdf download?"

$
0
0

Hello,

I'm currently building a custom plugin that retrieves some data from the database include the file name of an existing pdf. Afterwards, I use FPDF and FPDI to make a few alterations to the existing pdf (like stamping it with some user data). Then, I would like the user to be able to download the new pdf with the alterations. However, the problem is that when the download button is clicked (it's a submit button with some hidden fields and it uses $_POST so technically it's a form submission because I need it to do somethings shortly before the download begins), the download does not start but I get this error on the page:

FPDF error: Some data has already been output, can't send PDF file (output started at /home/www/mysite.com/wp-includes/admin-bar.php:844)

I tried putting this is a function that I use in an action but it didn't work.

function dl_force() {
$pdf->Output(WP_PLUGIN_DIR . "/my-plugin-folder/tempcontent/modify/modified_pdf.pdf", "D");
}

add_action('init', 'dl_force');

I also tried this:

function dl_force() {
$pdf->Output(WP_PLUGIN_DIR . "/my-plugin-folder/tempcontent/modify/modified_pdf.pdf", "D");
}

add_action('admin_init', 'dl_force');

And this:

function dl_force() {
$pdf->Output(WP_PLUGIN_DIR . "/my-plugin-folder/tempcontent/modify/modified_pdf.pdf", "D");
}

add_action('wp_head', 'dl_force');

And this:

function dl_force() {
$pdf->Output(WP_PLUGIN_DIR . "/my-plugin-folder/tempcontent/modify/modified_pdf.pdf", "D");
}

add_action('template_redirect', 'dl_force');

but none of them worked. So instead I tried to send the new pdf to the modify folder and use headers to force the download but that didn't work either. I tried transferring the pdf code to another page so that I can remove any kind of space but that didn't work either. So I decided to make a download.php page where I put some headers and use javascript to redirect to it as soon as the download ( / submit) button is clicked but it doesn't redirect. It just loads the same page but this time without an error. However, when I access the download.php page directly, the download starts.

Here is the content of the download.php:

<?php
    header('Content-Type: application/pdf');
    header('Content-disposition: attachment;filename=wp-content/plugins/my-plugin-folder/tempcontent/modify/modified_pdf.pdf');
    readfile('wp-content/plugins/my-plugin-folder/tempcontent/modify/modified_pdf.pdf');
    ?>

So my question is, how can I force the pdf to download? Is there anything that I can use to trigger the headers to start the force download before the admin-bar.php or any other thing on the page? Or is there any another way I can force the download?

I know it's a long read so thanks for reading and I'll appreciate any help!

By the way, I've also tried header('Location: http://.....'); but that didn't work either. :(

Eric Teubert on "Optimize plugin phpunit test suite startup speed"

$
0
0

Hi,

I'm using the basic test setup from https://develop.svn.wordpress.org/trunk/ but with my own tests. However, startup time is about 15 seconds and that seems a bit much ... ?

Here's my setup:

- I have a single test that just checks if my plugin is active
- I echo the time at the beginning and end of bootstrap.php. That's only 3 seconds. After that it takes ~10s until PHPUnit 4.6.10 by Sebastian Bergmann and contributors. appears. What's happening in that time and can I speed it up?

vagrant@vvv:/my/plugin$ phpunit tests/phpunit/void_test.php

start bootstrap 1435391893.2444
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.

finish bootstrap 1435391896.1637
PHPUnit 4.6.10 by Sebastian Bergmann and contributors.

Configuration read from /srv/www/podlove-publisher/htdocs/wp-content/plugins/podlove-podcasting-plugin-for-wordpress/phpunit.xml

.

Time: 17.27 seconds, Memory: 30.00Mb

OK (1 test, 1 assertion)

Viewing all 8245 articles
Browse latest View live




Latest Images