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

andy_woz on "Custom Query - List Users by last name"

$
0
0

I have a select menu for a search function populated by a custom query ordered by user last name that is working fine but I have a clunky exclude to stop the admin user being listed:

<select name="author" id="select-author">
<option value="">Select Author</option>

<?php
$excluded = "1"; //exclude users by ID
$authors = $wpdb->get_results("SELECT * FROM $wpdb->users INNER JOIN $wpdb->usermeta ON ($wpdb->users.ID = $wpdb->usermeta.user_id) WHERE $wpdb->usermeta.meta_key = 'last_name' AND $wpdb->usermeta.user_id NOT IN ($excluded) ORDER BY $wpdb->usermeta.meta_value ASC");

foreach($authors as $author):
$select .='<option value="'. $author -> user_nicename .'">' . $author -> display_name . '</option>';
endforeach;
print $select;
?>

</select>

At some point I'm sure we are going to have more users and I don't want to be excluding them based on their ID but I can make do by limiting the users to all those with the author role. I don't see user_role currently listed in the resulting array for $authors. What I'd like to do is to add to the query and instead of excluding user ID's have only users with the role of author in the results. What's the best way to do this? I've tried a few things but nothing works so far......

Thanks!


designerfosh on "Filter Function based on Author Meta Field Values"

$
0
0

I have a custom field with radio boxes added to my WP Authors Profile. I am also using a wp contributors function to display all the authors. I would like to filter the authors this function displays based on whether or not the custom radio box is checked yes or no.

Any help is appreciated!

Contributors Function
http://www.wpbeginner.com/wp-tutorials/how-to-display-an-author-list-with-avatars-in-wordpress-contributors-page/

Custom user field
$featauth = get_the_author_meta( 'featauth', $user->ID);

Adrian Toll on "apply_filters the_content not triggering oembed even in the loop"

$
0
0

I've been trying to get a custom wysiwyg field to output as it normally would when using the_content(). To this end I've been passing the contents of the custom field through apply_filters using the_content filter. However, all this is doing is parsing shortcodes without triggering oembed magic for YouTube URLs.

I've read quite a few blog posts that suggest it needs a post ID (i.e. it needs to be in the loop) leading to solutions like this - http://wordpress.org/support/topic/oembed-filter.

However, my code *is* in the loop as you can see from the_content() being used at the top, which outputs as expected and outputs the correct embed code, so I'm scratching my head about why it's not picking up the YouTube URLs and using oembed.

The other post I've read is here - http://dancameron.org/code/wp_embed-oembed-filter-the_content-post_content/ - which talks about caching, but I'm not quite sure what that refers to (I've had a look at the WP_Embed class, and can't figure it out from there).

Does anyone have any ideas why this wouldn't be picked up? My code is below, which uses slt_cf_field_value() from Developers Custom Fields (http://wordpress.org/plugins/developers-custom-fields/) to retrieve the custom field values:

the_content();

if (slt_cf_field_value('tab_title_1') != '') {

    echo '<div id="tab-container" class="tab-container">';

        echo '<ul class="etabs">';

        for ($i=1;$i<6;$i++) { if (slt_cf_field_value('tab_title_'.$i) !== '') {

            echo '<li class="tab"><a href="#tabs'. $i .'">'. slt_cf_field_value('tab_title_'.$i) .'</a></li>';

        }}

        echo '</ul>';

        for ($i=1;$i<6;$i++) { if (slt_cf_field_value('tab_title_'.$i) !== '') {

            $tabContent = apply_filters('the_content', slt_cf_field_value('tab_content_'.$i));

            echo '<div class="tab-content" id="tabs'. $i .'">'. $tabContent .'</div>';

        }}

    echo '</div>';

}

sevenkader on "Use str_replace to remove beginning of title possible?"

$
0
0

Is it possible to delete the beginning of a title?

For example, if I want to delete anything that comes behind the "-" including that itself

Example: Bob Billy - Hello Lyrics --> Hello

is it possible?

tommydamani on "Keep YouTube video unsharable?"

$
0
0

How to i embed a YouTube video into my WP blog & have it so that no one can click the video and then go to YouTube, take the link and share that link?

I'm running a membership based website you see and i need to make sure people don't share my video links.

If not YouTube then is there another way to do what i need?

d0cpaul on "Canvas Theme Custom Post Types"

$
0
0

So I've been searching and reading through the support forums for hours to resolve this so I thought I would finally ask. How do I customize a CTP template in the WooThemes Canvas theme? I created my own custom post type called, "disneyland". I duplicated content.php and archive.php and renamed it to content-disneyland.php and archive-disneyland.php and tried customizing content-disneyland but none of my changes reflect the CTP at all. What am I doing wrong?

Here is the code I used to register the CTP in functions.php:

// Register Custom Post Type

function custom_post_type() {

$labels = array(
'name' => _x( 'Disneyland', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Disneyland', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Disneyland', 'text_domain' ),
'parent_item_colon' => __( 'Parent Information:', 'text_domain' ),
'all_items' => __( 'All Disneyland Info', 'text_domain' ),
'view_item' => __( 'View Disneyland Info', 'text_domain' ),
'add_new_item' => __( 'Add New Info', 'text_domain' ),
'add_new' => __( 'Add New Info', 'text_domain' ),
'edit_item' => __( 'Edit Disneyland Info', 'text_domain' ),
'update_item' => __( 'Update information', 'text_domain' ),
'search_items' => __( 'Search products', 'text_domain' ),
'not_found' => __( 'No Disneyland Information Found', 'text_domain' ),
'not_found_in_trash' => __( 'No Disneyland Information found in Trash', 'text_domain' ),
);
$rewrite = array(
'slug' => 'disneyland',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => __( 'disneyland', 'text_domain' ),
'description' => __( 'Disneyland Key Information', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'post-formats', ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => '/Disneyland-Custom-Post-Type-Menu-Icon.png',
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'products', $args );

}

// Hook into the 'init' action
add_action( 'init', 'custom_post_type', 0 );

}

[Please always use the code buttons when posting code]

If you know of a good tutorial or know what the problem is please help!

rcorr on "Displaying a custom error message"

$
0
0

Hello,

I am following along a tutorial in Yannick Lefebvre Plugin Cookbook on saving user-submitted content. The form saves the data in the database correctly, however if a required field is missing, I received the following instead of the abort message I provided (see below):

Comment Error
Please enter all fields correctly to post a comment.

I believe this is the default message for the comment form. The code I have is

if ( wp_verify_nonce( $_POST['br_user_form'],'add_review_form' ) &&
!empty( $_POST['book_title'] ) &&
!empty( $_POST['book_author'] ) &&
!empty( $_POST['book_review_text'] ) &&
!empty( $_POST['book_review_book_type'] ) &&
!empty( $_POST['book_review_rating'] ) ) {
   // Insert data in database and other stuff
   exit;
} else {
  // Display message if any required fields are missing
  $abortmessage = 'Some fields were left empty. Please ';
  $abortmessage .= 'go back and complete the form.';
  wp_die($abortmessage);
  exit;
}

To confirm that the program reaches the error block, I placed a JavaScript alert just before the $abortmessage variable and it shows up. Therefore, I am reaching that block of code if a field is empty.

If anyone can shed some light why the custom error message does not show, I will be much appreciated.

Thanks in advance.

dealsoff on "Want to overwrite existing permalinks"

$
0
0

can someone tell me how i can overwrite an existing post with same permalink..

for example:
i have an existing post with the name:
hello-world

when i create new post with hello world, it will create
hello-world-2
I want this new post to have the permalink of hello-world and replace the old post content.. is it possible?


Shmoo on "post type items to back-end wp_nav_menu"

$
0
0

Just curious where to start,

I found already how you can add a Post Type to the wp menu option (back-end) but how can you control what is taken from that post type to show inside a menu.

By default when you add a Post Type to this menu option it will take the title + make a link of the Post Type but what if you want to add something to this info.

I'm looking at this because I would like to make the easiest bbPress forum menu in the world and for grouping single forums together.
Right now, there is a menu option but it only shows the forum title I would like to add topic counts + post counts to this.

Does anybody know where to start or maybe you know a plugin who does something similar so I can look at the code and go from there..

Thanks.

Jason Ho on "How can i change the author info on the plugin that i dev?"

josh5723 on "Custom Header (Text, Not Image) Per Page?"

$
0
0

I am working with a site for a local business which has multiple locations. We're using a premium theme which has a custom option to input our phone number into the header. The issue is we want a different phone number for certain pages. If I leave the custom theme option for the phone number blank, it'll show up blank on the site.

I know very little about coding, so I'm hoping this is easily doable. Is there a way to create 2 separate header.php files and tell certain pages to draw from say, header2.php (which would have the different phone number hard coded into it) ?

Or any other solutions/plugins?

Thanks!

ADUpchurch on "Can't Remove or Download Any Plugins"

$
0
0

Earlier today I downloaded W3 Total Cache. It totally threw my website into a panic to where it shut down my website. I have since gotten the website back online, except I cannot remove or download any plugins from the install menu. I am able to pull plugins up, and look at them with the only option of Details and not the Install Now option. If I attempt to remove a plugin I would could deactivate, which does nothing but reloads the active plugins page. I have deleted all remnants of W3 Total Cache I believe. I don't know what else to do.

My website is: http://www.creativesolvibrations.com just incase you may need to pull something up from there.

everyeurocounts on "using Filters in functions"

$
0
0

Hi,

I have a filter (1st filter) that runs when the theme loads at priority 10 (default)(i assume it does as its in the theme functions theme override of the childtheme).

Within the theme functions override i have another function that runs on a different filter with priotiy set to 100. Within this function I am adding another filter to modify the 1st filter results but its not firing.

Are filters available for use in functions and does it look for the function to be before the call?

powermaniac on "Permalink modification on wp_insert_post"

$
0
0

Hello, I'm not sure if this is the right area... When adding a new post with wp_insert_post, all periods (.) in the url are replaced with dashes. This is usually fine for SEO, but in this particular case, I would like them to remain as periods. I have a site that needs to have other site URL's in my URL.

For Example:

mysite.com/domain/www.wordpress.org

When I use wp_insert_post, it changes to:

mysite.com/domain/www-wordpress-org

Any ideas?

josh0505 on "What is this?"

$
0
0

**I can't log in because of this crap below. I'm not a pro site builder so I don't understand code I just kept working on my site till I figured it out. I cleared my cookies and even changed my settings, still I have found no solution.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home1/josh0505/public_html/wp-content/plugins/hcard-widget/hCard_widget.php:614) in /home1/josh0505/public_html/wp-content/plugins/easy-contact/econtact.php on line 112

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home1/josh0505/public_html/wp-content/plugins/hcard-widget/hCard_widget.php:614) in /home1/josh0505/public_html/wp-content/plugins/easy-contact/econtact.php on line 112

Warning: Cannot modify header information - headers already sent by (output started at /home1/josh0505/public_html/wp-content/plugins/hcard-widget/hCard_widget.php:614) in /home1/josh0505/public_html/wp-includes/pluggable.php on line 896


HCSdesigns on "iframe - java script hack"

$
0
0

Hey guys - is there anything simple I can do? I have some sites that are being hacked. It happened a week ago - we got it cleaned up. Beefed up security, changed passwords, updated wordpress versions, removed plugins we were not using and it is happening all over again.

http://www.hcsdesigns.com
http://www.cepsn.org

I am having difficulty finding the exact piece of java script I need to remove.

I have learned the iframe is auto generated when a visitor or search engine goes to my sites...

here it is: <iframe name=Twitter scrolling=auto frameborder=no align=center height=1 width=1 src=http://[redacted by moderator]/post.php?id=3696496200></iframe>

_alexsmith1 on "Automatically Tag Post Based on Specific Category"

$
0
0

Is there any way that I can tell WordPress to automatically use a certain tag when posting in a certain category? The reason I am asking is because my theme has a featured posts slider that only has an option to grab posts by a specific tag. However, I don't want the inconvenience of tagging all posts in the category that I want to be in the slider ("Music News" category). Is there any way that I can tell WordPress to automatically tag all posts that I publish in the Music News category with a tag such as "news"? Again, I do not want to have to manually tag the posts.

My home page: theoriginalsociety.com

charlyanderson on "Change Metabox title"

$
0
0

Good afternoon,

I am trying to change a metabox title within the Januas Wordpress Theme from "more" to "contact". I have sifted through all the files and change any references I could see but it did not work.

Here is an example of the code:-

// otherinfo

    $meta_boxes[] = array(

        'id' => 'januas_otherinfo',

        'title' => __('Other', 'januas'),

        'pages' => array('ja-event'),

        'context' => 'normal',

        'priority' => 'high',

        'show_names' => true,

        'fields' => array(

            array(

                'name' => __('Visible', 'januas'),

                'desc' => __('Select Yes to show the box in the event page, No to hide it.', 'januas'),

                'id' => 'januas_otherinfo_visible',

                'type' => 'select',

                'options' => array(

                    array('name' => __('Yes', 'januas'), 'value' => 'y'),

                    array('name' => __('No', 'januas'), 'value' => 'n'),

                )

            ),

            array(

                'name' => __('Position', 'januas'),

                'desc' => __('Select the preferred position for the box.', 'januas'),

                'id' => 'januas_otherinfo_position',

                'type' => 'select',

                'options' => array(

                    array('name' => __('Main', 'januas'), 'value' => 'main'),

                    array('name' => __('Sidebar', 'januas'), 'value' => 'sidebar'),

                )

            ),

            array(

                'name' => __('Order', 'januas'),

                'desc' => __('Insert the box order (ex: 1).', 'januas'),

                'id' => 'januas_otherinfo_order',

                'std' => 6,

                'type' => 'text_small'

            ),

            array(

                'name' => __('Show Title', 'januas'),

                'desc' => __('Select Yes to show the box title, No to hide it.', 'januas'),

                'id' => 'januas_otherinfo_showtitle',

                'type' => 'select',

                'options' => array(

                    array('name' => __('Yes', 'januas'), 'value' => 'y'),

                    array('name' => __('No', 'januas'), 'value' => 'n'),

                )

            ),

            array(

                'name' => __('Show in Top menu', 'januas'),

                'desc' => __('Select Yes to show the menu item in the event page top menu, No to hide it.', 'januas'),

                'id' => 'januas_otherinfo_showinmenu',

                'type' => 'select',

                'options' => array(

                    array('name' => __('Yes', 'januas'), 'value' => 'y'),

                    array('name' => __('No', 'januas'), 'value' => 'n'),

                )

            ),

            array(

                'name' => __('Content', 'januas'),

                'desc' => __('Arbitrary text or HTML.', 'januas'),

                'id' => 'januas_otherinfo_text',

                'type' => 'wysiwyg'

            ),

            array(

                'name' => '',

                'desc' => '',

                'id' => 'januas_otherinfo_backtotop',

                'type' => 'backtotop'

            )

        )

    );

I am obviously doing something wrong, could anyone point me in the right direction please?

RealSouthpaw on "Custom settings for theme sidebar"

$
0
0

I wanted to try doing my first own theme and I'm doing custom settings for it right now. I want user to have a chance to decide if s/he wants sidebar be located on left or right side of the screen and in order to do that setting I studied these tutorials:

http://wp.tutsplus.com/tutorials/theme-development/create-a-settings-page-for-your-wordpress-theme/
http://codex.wordpress.org/Creating_Options_Pages

With these I managed to do settings page and form with radiobuttons but since all tutorials I've found are using text form as an example I can't now figure out how to save the radiobutton setting and how to use it in actual theme. I would be really grateful if somebody would explain to me what to do. Here is the code I have for settings page this far:

<?php //Settings page for theme is done here
function setup_theme_admin_menus() {
	add_menu_page('Theme Options', 'Theme Options', 'manage_options', 'theme_settings', 'theme_options', '', '58');

	add_submenu_page('tut_theme_settings', 'Sidebar', 'Sidebar', 'manage_options', 'theme_settings', 'theme_options');

	//Call register settings function
	add_action( 'admin_init', 'register_mysettings');
}

// This tells WordPress to call the function named "setup_theme_admin_menus"
// when it's time to create the menu pages.
add_action("admin_menu", "setup_theme_admin_menus");  

//Registers options needed for this theme
function register_mysettings() {
  register_setting( 'themeoption-group', 'sidebar_location' );
}

//This is the actual settings page for theme
function theme_options() {
	// Check if current user is allowed to update options
	if (!current_user_can('manage_options')) {
		wp_die('You do not have sufficient permissions to access this page.');
	}
	$sidebar_location = get_option("sidebar_location"); ?>

	<div class="wrap">
		<h2>Theme Options</h2>
		<hr>
		<form method="post" action="options.php">
			<?php
			settings_fields( 'themeoption-group' );
			do_settings_sections( 'themeoption-group' ); ?>

			<label>Sidebar location:</label><br/>
			<input type="radio" name="sidebarlocation" value="right" <?php if($sidebar_location == "right"){echo "checked";} else{ }?>>Right<br>
			<input type="radio" name="sidebarlocation" value="left" <?php if($sidebar_location == "left"){echo "checked";} else{ }?>>Left
    			<input type="hidden" name="update_settings" value="Y" />
			<?php submit_button(); ?>
		</form>
	</div>

<?php 

	if (isset($_POST["update_settings"])) {
    		$sidebar_location = esc_attr($_POST["sidebarlocation"]);
		update_option("sidebar_location", $sidebar_location);
	} ?>

appleisle on "Post Author URL displays Username NOT Nickname"

$
0
0

I have found earlier requests on this Username appearing in the URL but no real answers & most were 4 to 5 years old - so here goes again:

PROBLEM: Posts are created and display the Nickname (Not Login Username) yet when you click on that Nickname to see a summary of all the posts by that person the URL that appears reverts to:www.??????/author/username/

ISSUE is this gives the "hacker" your real Log In Username. Yes I know we all should have good passwords but as a general WP user I could not believe this is a standard WP code action.

I have just last night had many attempts to hack in at Log In (protected by All In One WP Security & Firewall) and was amazed they had my Username to attempt to crack in (NO it is not Admin!).

That prompted me to think they had cracked into my DB to get the username, then I found via searching the Forum some notes about the problem and sure enough I check my site and bingo the Post Summary for a nickname provides the Username...!!!!

I saw there is a Plug-in SX_Username is this the ONLY OPTION or am I missing some standard WP code/setting issue?

Any help much appreciated.

Viewing all 8245 articles
Browse latest View live




Latest Images