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

christopherstamper on "WooCommerce: Checking a wp-user field before allowing checkou"

$
0
0

I have a custom user field defined in WordPress, (Boolean)Authorized. I defined this field using another plugin (MemberPress) and it's accessible using the slug mepr_authorized.

I would like to check this field in the WooCommerce checkout process. If it's FALSE/0, then the user should not be able to complete the checkout process - and instead be presented with UI indicating as such. The field itself should not be displayed in an editable fashion.

Any ideas how I can do this?

One thought I had was a custom, non-editable but required field in WooCommerce, that I would automatically set via PHP (basically retrieve the user value and assign it). Is this feasible?

Any feedback is awesome. Thanks!


Fandabydozy on "Add ID selector for each menu item in the WP Menus panel"

$
0
0

Is it possible to add an id tag for each menu item from within the WordPress 'Menus' panel. So it would be possible to go to "Appearance" -->"Menus" --> and then in the screen options panel have an extra checkbox for 'ID' to assign a unique id selector to each main menu item so it can be individually targeted via id=“myUniqueID”.

I’ve included a visual of what I would like to achieve as far as the admin side goes, http://buildtest.co.uk/id-box.jpg.

Thanks

Meredith Matthews on "Filtering category dropdown?"

$
0
0

I would like to display a dropdown list of custom taxonomy categories on my site, so that users can navigate directly to category listings, and I would like the dropdown to both drop down and have a text input to filter or at least shift the list to the right spot (it's a very long list). I haven't been able to find a plugin or a code snippet that does this, and while I'm pretty sure there's a name for this sort of field, *I can't even figure out what it's called*. Any help would be greatly appreciated.

francoeurdavid on "Shortcode to Query custom Post-type"

$
0
0

Hi,

I followed this to add a content-block to my theme. I want to extend it with the Shortcodes.

I want to be able to write :
[content_zone name="col-1"]

The code should return the content of the content-block directly where the Shortcode is place within the page. My functions.php look as follows :

function content_zone_func( $atts ) {
	extract( shortcode_atts( array(
		'name' => ''
	), $atts ) );

	return get_content_zone($name);

}
function get_content_zone( $name ){

	$content_block = new WP_Query(array('post_type'=>'content-block', 'posts_per_page'=>1, 'content-position'=>$name));

	if($content_block->have_posts()){
		$content_block->the_post();
		$content = the_content();
		wp_reset_postdata();
	  	return $content;
	}
}
add_shortcode( 'content_zone', 'content_zone_func' );

The things return the good content but it is not placed correctly in the page. Let's say I use this content in my page :

Hello, this is the content of the zone :
[content_zone name="col-1"]
There you go.

It would be posted like this on the page :

CONTENT OF THE ZONE

Hello, this is the content of the zone :
There you go.

It looks like the main loop is overrided by this secondary loop.

If I replace the function by simply returning a string, everything works fine.

netcollab on "Want to remove password from login/registration page"

$
0
0

Hi,

I want to remove password from the login page such that only username is required for logging in. So in the registration too , i will only have username . My requirement is to create a username from the admin panel and using only the username , a user can login to their panel .

Please let me know how i can achive this

Thanks
Naveen

ajcke on "wp_list_pages Output Parent and Child Pages"

$
0
0

I've been using the code below to auto display pages and child pages in a sidebar. Our site has a few parent pages and the rest of the pages are all nested within these. Right now the code displays the parent page, child pages, and all grandchildren pages no matter what page a user is on. I would like to modify the code to display the parent page for the title and child pages ONLY in the ul. It would also be cool to be able to leave out a page if needed.

<?php
  if($post->post_parent) {
  $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
  $titlenamer = get_the_title($post->post_parent);
  }

  else {
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  $titlenamer = get_the_title($post->ID);
  }
  if ($children) { ?>

  <h2> <?php echo $titlenamer ?> </h2>
  <ul>
  <?php echo $children; ?>
  </ul>
<?php } ?>

Example of Output
If a user is on any of the pages below the menu looks the same:
<h2>Athletics</h2>

  • Baseball
    • HS Baseball
  • Basketball
    • HS Basketball – Boys
    • HS Basketball – Girls
    • JH Basketball – Boys
    • JH Basketball – Girls
  • Cheerleading
    • HS Cheerleading
    • JH Cheerleading
  • Football
    • HS Football
    • JH Football
  • Softball
    • HS Softball
  • Track & Field
    • HS Track & Field – Boys
    • HS Track & Field – Girls
    • Indoor Track
    • JH Track & Field – Boys
    • JH Track & Field – Girls
  • Volleyball
    • HS Volleyball
    • JH Volleyball

Desired Output Example
If a user is on the basketball page the menu only looks like this:
<h2>Basketball</h2>

  • HS Basketball – Boys
  • HS Basketball – Girls
  • JH Basketball – Boys
  • JH Basketball – Girls

If a user is on the athletic root parent page the menu would look like this:
<h2>Athletics</h2>

  • Baseball
  • Basketball
  • Cheerleading
  • Football
  • Softball
  • Track & Field
  • Volleyball

ced1870 on "auto database update"

$
0
0

Hi
I'm writing a plugin that adds an option on each widget. It works, but at a certain time the "options" database where my value is stored changes and the value become empty.
I have just seen a waiting icon on the top of the sidebar title, may be this is related to my problem but I don't know

so the problem is that my value is automatically empty after a certain time without any action
Do you have an idea of what is the problem ?
Thank you
CEd

hays298 on "Open Graph tags for Facebook"

$
0
0

My WordPress links have just stopped working on Facebook. They were working fine up until a few days ago. I checked them on the Facebook debugger and it comes up with the following warnings:

The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
The 'og:title' property should be explicitly provided, even if a value can be inferred from other tags.
The 'og:description' property should be explicitly provided, even if a value can be inferred from other tags.

I've tried added the following code to my header, but it hasn't made a difference:

<meta property="og:title" content="<?php get_post; ?>
<meta property="og:url" content="<?php get_page_link; ?>
<meta property="og:description" content="<?php the_excerpt(); ?>

Any ideas?

Also has anyone come across this before or know why it seems to have suddenly become a problem?

Links here:

Website
Facebook


gorka.molero on "Turning IMGs into divs with background-image (preg_replace)"

$
0
0

Hey guys!

I'm trying something out but as I'm not versed in PHP it feels like smashing my head against random walls.

I need to alter the output of image tags. I want to replace the img tag for a div with a background image, to achieve sort of this effect.

I'm working around this function, in functions.php. This only takes the full image code and outputs it into the background-image url. I would need to extract the SRC.

function turnItIntoDiv( $content ) {

   // A regular expression of what to look for.
   $pattern = '/(<img([^>]*)>)/i';
   // What to replace it with. $1 refers to the content in the first 'capture group', in parentheses above
   $replacement = '<div class="full-image" style="background-image: url("$1")"></div>';

   // run preg_replace() on the $content
   $content = preg_replace( $pattern, $replacement, $content );

   // return the processed content
   return $content;
}

add_filter( 'the_content', 'turnItIntoDiv' );

Thank you all

jeezy on "RSS Feed Post Category ID not Name"

$
0
0

Hi, I'm trying to get a WordPress RSS feed to also include the category ID value and not just the category name. The reason is I'm importing an RSS feed into another system and I want to be able to perform searches based on category ID number. I'd like to avoid doing string searches based of the category name.

Any thoughts or suggestions?

Rossini on "Jquery dropdowns not functioning on touch device"

$
0
0

Hi I have created a homepage that allows has 5 jquery jump menus as quick links on it using a simple method found here:

http://www.codecaven.co.uk/jquery-jump-menu.php

This works great until it comes to touch devices where the links are not actioned.

I have tried to impliment CSS drop downs instead based on the suckerfish system but again on the iphone / ipad in particular it is just displaying an unordered list and not a drop down.

If anyone can help suggest a fix / work around or plugin that will allow me to replace these within the body content it would be massively appreciated.

Thanks in advance.
Ross

Kic00 on "tinyMCE upgrade in 3.9 broke javascript in a plugin"

$
0
0

Hi - the WP upgrade to 3.9 broke a plugin we are using (which isn't supported by its author anymore).

The lines of javascript that broke were lines where the author was trying to override the wpeditimage plugin to tinyMCE with this line:
tinymce.plugins.wpeditImage.prototype._do_shcode = function(co) {
...
}

That line returns a TypeError in the console:
TypeError: 'undefined' is not an object (evaluating 'tinymce.plugins.wpeditimage.prototype')

Is this sort of monkey patching no longer possible? Or do I need a new path or something? The console also isn't showing the wpeditimage object at all as an addressable entity.

lsilver on "Automatically Edit And Save A Post Upon Publishing"

$
0
0

I'm using a plugin which requires a post to be updated before it's functionality kicks in. It is too time consuming to do this each time I make a post. I have to edit it, and then save it (with no changes).

I tried to find a plugin that could do this but no luck.

Does anybody have any idea how I could go about this? I'm presuming a custom plugin but I have no clue what to do.

Thanks.

ced1870 on "add js only if condition is true"

$
0
0

Hi
I'm developping my plugin and it works :), that is the good news
Now I would like to make it correctly.
1/ I have a fonction that check if a word exist in the content:

add_filter('the_content', array( $this, 'searchkey'));

2/ I have an action to load my CSS and JS files

add_action('wp_enqueue_scripts', array( $this, 'load_assets_files'));

The problem here is that even if my word is not found in the content, the CSS and JS files will be loaded. I want to
if (word is found) {
load my js and css
}

but if I use <script type="text/javascript"> in my condition, it will be added for each post content. It needs to be added into the head.
If I use a "add_action('wp_head')" into my condition which is in the_content filter, then it does not work.

rocke on "Custom - Parameter in contact-form-manager Plugin"

$
0
0

I am using "contact-form-manager" Plugin for my inquiry page

i have many field but need help in 2 place of field

Textbox and Select option

all is working fine , from back end i can create forms, and its displaying properly in front end

But there is some change i need to do :

localhost/project/?page_id=56&motion=aamir-khan&id=2 - where "?motion" is my custom Taxonomy , not custom post . AND pageid=56 is my inquiry page

Send Details about Motion hence when i come to inquiry page

my textbox should be fill be : aamir-khan ( as per motion taxnomy )
and my select option should be selected as : motion ( as per id:2 )

as i have already pass two parameter through above link

How i can do the same

https://wordpress.org/plugins/contact-form-manager/


Manoj H L on "Add content/meta tab between Title and Content in WP Editor"

$
0
0

I would like to some meta tabs or suggestions for user editing the post.
The best place to add that content will be between Title and Content Editor.
Is their any action or filter to achieve this..

KarlJan on "Inserts into procedures"

$
0
0

Hello, I've been playing arround with procedures and tried putting the comment insert into a procedure. I've got some trouble and was wondering if you guys could take a look.

function wp_insert_comment($commentdata) {
	$comment_ID = comment_ID;
	$comment_post_ID = comment_post_ID;
	$comment_author = comment_author;
	$comment_author_email = comment_author_email;
	$comment_author_url = comment_author_url;
	$comment_author_IP = comment_author_IP;
	$comment_date = comment_date;
	$comment_date_gmt = comment_date_gmt;
	$comment_content = comment_content;
	$comment_karma = comment_karma;
	$comment_approved = comment_approved;
	$comment_agent = comment_agent;
	$comment_type = comment_type;
	$comment_parent = comment_parent;
	$user_id = user_id;
	global $wpdb;
	extract(wp_unslash($commentdata), EXTR_SKIP);

	if ( ! isset($comment_author_IP) )
		$comment_author_IP = '';
	if ( ! isset($comment_date) )
		$comment_date = current_time('mysql');
	if ( ! isset($comment_date_gmt) )
		$comment_date_gmt = get_gmt_from_date($comment_date);
	if ( ! isset($comment_parent) )
		$comment_parent = 0;
	if ( ! isset($comment_approved) )
		$comment_approved = 1;
	if ( ! isset($comment_karma) )
		$comment_karma = 0;
	if ( ! isset($user_id) )
		$user_id = 0;
	if ( ! isset($comment_type) )
		$comment_type = '';

	//$data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');
	$wpdb->insert($wpdb->comments, '$comment_ID','$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_karma', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id');
	//$wpdb->insert($wpdb->comments, 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');

	$id = (int) $wpdb->insert_id;

	if ( $comment_approved == 1 )
		wp_update_comment_count($comment_post_ID);

	$comment = get_comment($id);

	/**
	 * Fires immediately after a comment is inserted into the database.
	 *
	 * @since 2.8.0
	 *
	 * @param int $id      The comment ID.
	 * @param obj $comment Comment object.
	 */
	do_action( 'wp_insert_comment', $id, $commen );

	wp_cache_set( 'last_changed', microtime(), 'comment' );

	return $id;
}

So here I send all the variables to another function, because it didn't work with the array solution that was previously used. So i send the variables to

function _insert_replace_helper( $table, $comment_ID, $comment_post_ID, $comment_author, $comment_author_email, $comment_author_url, $comment_author_IP, $comment_date, $comment_date_gmt, $comment_content, $comment_karma, $comment_approved, $comment_agent, $comment_type, $comment_parent, $user_id, $format = null, $type = 'INSERT' ) {

$sql = "CALL CommentsProcedure('$comment_ID', '$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_karma', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id')";

		return $this->query( $this->prepare( $sql, $comment_ID, $comment_post_ID, $comment_author, $comment_author_email, $comment_author_url, $comment_author_IP, $comment_date, $comment_date_gmt, $comment_content, $comment_karma, $comment_approved, $comment_agent, $comment_type, $comment_parent, $user_id ) );
	}

And heres the procedure i made

DELIMITER $$

CREATE PROCEDURE <code>CommentsProcedure</code>(IN comment_ID bigint(20), IN comment_post_ID bigint(20), IN comment_author tinytext, IN comment_author_email VARCHAR(100), IN comment_author_url VARCHAR(200), IN comment_author_IP VARCHAR(100), IN comment_date datetime, IN comment_date_gmt datetime, IN comment_content text,
 IN comment_karma int(11), IN comment_approved VARCHAR(20), IN comment_agent VARCHAR(255), IN comment_type VARCHAR(20), IN comment_parent bigint(20), IN user_ID bigint(20))
BEGIN
	INSERT INTO wp_comments(comment_ID, comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_karma, comment_approved, comment_agent, comment_type, comment_parent, user_id)
	VALUES(comment_ID, comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_karma, comment_approved, comment_agent, comment_type, comment_parent, user_id);

END
$$

DELIMITER ;

I have no clue what i do wrong, would be helpful if someone could give me some guidance.(Sorry for the bad english, not native speaker, feel free to ask if something is unclear.)
Thanks in advance

lmstreng on "Custom Post Type, the single-.php problem"

$
0
0

So I feel like I am doing something obviously simple, yet can't figure out what!

I've created my custom post type 'project' and created single-project.php to display the individual project posts. It's working (sort of), my problem is that instead of displaying the content for just the 1 post, it shows the content for all of the posts i've created.

Here's my single-project.php file:
http://pastebin.com/z20gVtEL

Any help would be much appreciated!

Pioneer Valley Web Design on "Current User Can on WPMU"

$
0
0

Glad to know I am not alone in this and none @ wp has an answer.

Nagytalp on "Display custom taxonomy part as "label on image" @home"

$
0
0

Hi!

I have this code:

< ?php
$p_terms = get_the_terms( $post->ID , 'tagportfolio' );
print_r($p_terms);
if ( $p_terms && ! is_wp_error( $p_terms ) ) {
$term_links = array();
foreach ( $p_terms as $p_term ) {
$term_links[] = $p_term->name;
}
$termslinks = join( ", ", $term_links );
echo '
'.$termslinks.'

';
}
?>

I wanna show the name of the custom taxonomy on the featured image on my home page as a clickable label. This code is works and the solution is inside of the but I don't know where.

At this moment the result look like this:

Array ( [6] => stdClass Object ( [term_id] => 6 [name] => Allegro [slug] => allegro [term_group] => 0 [term_taxonomy_id] => 45 [taxonomy] => tagportfolio [description] => Zene-bona [parent] => 0 [count] => 5 [object_id] => 1342 [filter] => raw ) ) Allegro

What I need is the last word! In this case the "Allegro".

And if can anybody tell me the perfect code for the solution then how can I style this label?

Another problem is in this case: When mouse over on this "result" the whole picture flashes extremly fast.

My site is here: http://www.irodalmibableves.hu

Thank You!

Viewing all 8245 articles
Browse latest View live




Latest Images