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

bucklea on "Adding a custom date field to Media Library Files"

$
0
0

Hello

I've added two custom fields, 'Publisher Name' and 'Publication Date' to allow me to add information to files in the Media Library (fields accessible through the Edit Media page). This has been done using the 'attachment fields to edit / attachment fields to save' method as below:

/**
* Add Publisher Name and Publication Date fields to media uploader
*
* @param $form_fields array, fields to include in attachment form
* @param $post object, attachment record in database
* @return $form_fields, modified form fields
*/

function be_attachment_field_credit( $form_fields, $post ) {
$form_fields['be-publisher-name'] = array(
'label' => 'Publisher Name',
'input' => 'text',
'value' => get_post_meta( $post->ID, 'be_publisher_name', true ),
'helps' => 'If provided, the publisher name will be displayed in the report homepage',
);

$form_fields['be-publication-date'] = array(
'label' => 'Publication Date',
'input' => 'date',
'value' => get_post_meta( $post->ID, 'be_publication_date', true ),
'helps' => 'Add Publication Date',
);

return $form_fields;
}

add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );

/**
* Save values of Publisher Name and Publication Date in media uploader
*
* @param $post array, the post data for database
* @param $attachment array, attachment fields from $_POST form
* @return $post array, modified post data
*/

function be_attachment_field_credit_save( $post, $attachment ) {
if( isset( $attachment['be-publisher-name'] ) )
update_post_meta( $post['ID'], 'be_publisher_name', $attachment['be-publisher-name'] );

if( isset( $attachment['be-publication-date'] ) )
update_post_meta( $post['ID'], 'be_publication_date', $attachment['be-publication-date'] );

return $post;
}

add_filter( 'attachment_fields_to_save', 'be_attachment_field_credit_save', 10, 2 );

My question is how can I add the Publication Date field as an actual Date (preferably as a date picker) rather than plain text, which is how it is recognised using the above code? I tried to specify the 'input' field as 'date', but this does not work. Any ideas?

Thanks in advance

Andy


rahulrrnair on "Add default location to all Custom Menu Links"

$
0
0

I have added 2 or three custom links to a menu that appears as inside the submenu drop down. I added them to link to specific sections using #div_id_name terms.Now I have to enter the complete url in order to link them to specific pages. Is there a function that would automatically link them to the parent page so that I just need to enter the # part?

Agence Myso on "Loading custom post types in two different places"

$
0
0

Hi everyone,

I am building a template in which custom post types must be loaded in two different templates.
You have two different menu items : NEWS / VIDEOS / PRINT.
Each month, the administrator will upload new projects in 'NEWS'. Theses projects will also be found in the two categories 'VIDEOS' and 'PRINT'.
Until now, I have built everything. The only problem remaining is : when you are in 'NEWS', you click for example on 'OCTOBER 2014', you have the list of projects (videos and/or prints). Then, if you click on the project, the present template system send the user on single.php, which means, you go out of the 'NEWS' menu to go to 'VIDEOS', which is normal, because I am using the_permalink();, but not good, as I am looking for staying in the same menu.
Anyone has an idea?
Thanks in advance.

fofobody on "Prevent duplicate posts on front page - loop help"

$
0
0

Hi all.. I'm hoping someone can prevent duplicate posts from showing up when using 2 queries.. Basically a "featured post" one and then a "latest posts" one. I'd like only 1 post to show up on the entire page.

Here is the code from the index.php file.. This is called Point Theme. Thanks!

http://pastebin.com/1QZMM9ci

trunyan on "Google links taking users to pharma site?"

$
0
0

I've been working on this since yesterday but still can't find out how this is happening. If you go to http://www.getzoomperformance.com everything works great. But if you google zoom performance and click on the link it takes you to a canadian pharmacy site. I've updated the theme and plugins but I haven't found how this is happening. Anyone got an idea of where I should look next? Thanks in advance

tmw27529 on "Multiple Custom Meta Boxes & Fields"

$
0
0

I have a Custom Post Type that has multiple Custom Meta Boxes, each with multiple Custom Fields. The code is a bit overwhelming and I wondering if there might be a better way to go about doing this.

// Add the DATE OF BIRTH and DEATH DATE Meta Box
function add_bldob_meta_box() {
    add_meta_box(
        'bldob_meta_box', // $id
        'Date of Birth and Death', // $title
        'show_bldob_meta_box', // $callback
        'obituaries', // $page
        'normal', // $context
        'default'); // $priority
}
add_action('add_meta_boxes', 'add_bldob_meta_box');

// Field Array
$prefix = 'bldob_';
$bldob_meta_fields = array(
	array(
    	'label' => 'Date of Birth',
    	'desc'  => '',
    	'id'    => $prefix.'bdate',
    	'type'  => 'date'
	),
	array(
    	'label' => 'Date of Death',
    	'desc'  => '',
    	'id'    => $prefix.'ddate',
    	'type'  => 'date'
	)
);

function show_bldob_meta_box() {
global $bldob_meta_fields, $post;

// Use nonce for verification
echo '<input type="hidden" name="bldob_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';

    // Begin the field table and loop
    echo '<table class="form-table">';
    foreach ($bldob_meta_fields as $field) {
        // get value of this field if it exists for this post
        $meta = get_post_meta($post->ID, $field['id'], true);
        // begin a table row with
        echo '<tr>
                <th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
                <td>';
                switch($field['type']) {
                    // case items will go here

					// Date of Birth
					case 'date':
						echo '<input type="text" class="datepicker" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
							<br /><span class="description">'.$field['desc'].'</span>';
					break;
					// Date od Death
					case 'date':
						echo '<input type="text" class="datepicker" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
							<br /><span class="description">'.$field['desc'].'</span>';
					break;

                } //end switch
        echo '</td></tr>';
    } // end foreach
    echo '</table>'; // end table
}

// Save the Data
function save_bldob_meta($post_id) {
    global $bldob_meta_fields;

    // verify nonce
    if (!wp_verify_nonce($_POST['bldob_meta_box_nonce'], basename(__FILE__)))
        return $post_id;
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
        return $post_id;
    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id))
            return $post_id;
        } elseif (!current_user_can('edit_post', $post_id)) {
            return $post_id;
    }

    // loop through fields and save the data
    foreach ($bldob_meta_fields as $field) {
        $old = get_post_meta($post_id, $field['id'], true);
        $new = $_POST[$field['id']];
        if ($new && $new != $old) {
            update_post_meta($post_id, $field['id'], $new);
        } elseif ('' == $new && $old) {
            delete_post_meta($post_id, $field['id'], $old);
        }
    } // end foreach
}
add_action('save_post', 'save_bldob_meta');

// Add the VISITATION Meta Box
function add_blvis_meta_box() {
    add_meta_box(
        'blvis_meta_box', // $id
        'Visitation Information', // $title
        'show_blvis_meta_box', // $callback
        'obituaries', // $page
        'normal', // $context
        'default'); // $priority
}
add_action('add_meta_boxes', 'add_blvis_meta_box');

// Field Array
$prefix = 'blvis_';
$blvis_meta_fields = array(
	array(
    	'label' => 'Date',
    	'desc'  => '',
    	'id'    => $prefix.'date',
    	'type'  => 'date'
	),

	array(
        'label'=> 'Time',
        'desc'  => '',
        'id'    => $prefix.'time',
        'type'  => 'text'
    ),

	array(
        'label'=> 'Location Name',
        'desc'  => '',
        'id'    => $prefix.'text',
        'type'  => 'text'
    ),

    array(
        'label'=> 'Location Address',
        'desc'  => '',
        'id'    => $prefix.'address',
        'type'  => 'textarea'
    ),

    array(
        'label'=> 'Details',
        'desc'  => '',
        'id'    => $prefix.'textarea',
        'type'  => 'textarea'
    )
);

function show_blvis_meta_box() {
global $blvis_meta_fields, $post;

// Use nonce for verification
echo '<input type="hidden" name="blvis_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';

    // Begin the field table and loop
    echo '<table class="form-table">';
    foreach ($blvis_meta_fields as $field) {
        // get value of this field if it exists for this post
        $meta = get_post_meta($post->ID, $field['id'], true);
        // begin a table row with
        echo '<tr>
                <th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
                <td>';
                switch($field['type']) {
                    // case items will go here

					// Date
					case 'date':
						echo '<input type="text" class="datepicker" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
							<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// Time
            		case "time":
    					echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// location name
					case 'text':
    					echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// address
					case 'address':
    					echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// details
					case 'textarea':
    					echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

                } //end switch
        echo '</td></tr>';
    } // end foreach
    echo '</table>'; // end table
}

// Save the Data
function save_blvis_meta($post_id) {
    global $blvis_meta_fields;

    // verify nonce
    if (!wp_verify_nonce($_POST['blvis_meta_box_nonce'], basename(__FILE__)))
        return $post_id;
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
        return $post_id;
    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id))
            return $post_id;
        } elseif (!current_user_can('edit_post', $post_id)) {
            return $post_id;
    }

    // loop through fields and save the data
    foreach ($blvis_meta_fields as $field) {
        $old = get_post_meta($post_id, $field['id'], true);
        $new = $_POST[$field['id']];
        if ($new && $new != $old) {
            update_post_meta($post_id, $field['id'], $new);
        } elseif ('' == $new && $old) {
            delete_post_meta($post_id, $field['id'], $old);
        }
    } // end foreach
}
add_action('save_post', 'save_blvis_meta');

// Add the SERVICE Meta Box
function add_blser_meta_box() {
    add_meta_box(
        'blser_meta_box', // $id
        'Service Information', // $title
        'show_blser_meta_box', // $callback
        'obituaries', // $page
        'normal', // $context
        'default'); // $priority
}
add_action('add_meta_boxes', 'add_blser_meta_box');

// Field Array
$prefix = 'blser_';
$blser_meta_fields = array(
	array(
    	'label' => 'Date',
    	'desc'  => '',
    	'id'    => $prefix.'date',
		'key' => 'servicedate',
    	'type'  => 'date'
	),

	array(
        'label'=> 'Time',
        'desc'  => '',
        'id'    => $prefix.'time',
        'type'  => 'text'
    ),

	array(
        'label'=> 'Location Name',
        'desc'  => '',
        'id'    => $prefix.'text',
        'type'  => 'text'
    ),

    array(
        'label'=> 'Location Address',
        'desc'  => '',
        'id'    => $prefix.'address',
        'type'  => 'textarea'
    ),

    array(
        'label'=> 'Details',
        'desc'  => '',
        'id'    => $prefix.'textarea',
        'type'  => 'textarea'
    )
);

function show_blser_meta_box() {
global $blser_meta_fields, $post;

// Use nonce for verification
echo '<input type="hidden" name="blser_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';

    // Begin the field table and loop
    echo '<table class="form-table">';
    foreach ($blser_meta_fields as $field) {
        // get value of this field if it exists for this post
        $meta = get_post_meta($post->ID, $field['id'], true);
        // begin a table row with
        echo '<tr>
                <th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
                <td>';
                switch($field['type']) {
                    // case items will go here

					// Date
					case 'date':
						echo '<input type="text" class="datepicker" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
							<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// Time
            		case "time":
    					echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// location name
					case 'text':
    					echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// address
					case 'address':
    					echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

					// details
					case 'textarea':
    					echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
        					<br /><span class="description">'.$field['desc'].'</span>';
					break;

                } //end switch
        echo '</td></tr>';
    } // end foreach
    echo '</table>'; // end table
}

// Save the Data
function save_blser_meta($post_id) {
    global $blser_meta_fields;

    // verify nonce
    if (!wp_verify_nonce($_POST['blser_meta_box_nonce'], basename(__FILE__)))
        return $post_id;
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
        return $post_id;
    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id))
            return $post_id;
        } elseif (!current_user_can('edit_post', $post_id)) {
            return $post_id;
    }

    // loop through fields and save the data
    foreach ($blser_meta_fields as $field) {
        $old = get_post_meta($post_id, $field['id'], true);
        $new = $_POST[$field['id']];
        if ($new && $new != $old) {
            update_post_meta($post_id, $field['id'], $new);
        } elseif ('' == $new && $old) {
            delete_post_meta($post_id, $field['id'], $old);
        }
    } // end foreach
}
add_action('save_post', 'save_blser_meta');

Here is a link to the site

I want to make sure I am doing things the best efficient way. The site currently works great for the client but I really want to be able to showcase it as an awesome custom WordPress solution (like in the WP community & with other developers).
Any suggestions are greatly appreciated!

d1neutral on "Help Please: Latest Wordpress Site Hackers Imerge in Nigeria"

$
0
0

Please i need help, my site has been hacked. The first day i saw my index file changed to the code below:
<html>
<title> Hacked by Zombie_L33T </title>
<h4> You got Hacked by Zombie_L33T|NIGERIAN CYBER ARMY </h4>
</br>
</br>
<h4> ALL WE JUST WANT IS A FREE AND FAIR ELECTION. NO KILLING NO FIGHTING, NO STEALING OF BALLOT BOX AND PAPERS
we are:- BatchFw3ak,CyberMarshal,Zombie_leet,MrPortal, Mcraj, REdspear,RedBullet, Uhuazion6</h4>
</html>
Plus another html file named "HB.html" with content :

<html>
<head>
<body bgcolor=black></center>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link href="http://www8.0zz0.com/2012/07/03/00/411542556.jpg" rel="SHORTCUT ICON"/>
<meta charset="utf-8" />
<TITLE>Owned By WH Worms </TITLE>

<script src="/google_analytics_auto.js"></script></head>
<link href="http://fonts.googleapis.com/css?family=Averia+Sans+Libre" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Iceland%3A700" rel="stylesheet" type="text/css">
<script src="/google_analytics_auto.js"></script></head>
<body>
<center><img src="http://auto.img.v4.skyrock.net/4151/63674151/pics/2960404521_1_7_SGy99uC5.jpg" width="390" height="250"
><a/>

<p></p><font face="Iceland" size="6" color="green" class="a">Hacked By WH worms [ ..::Morocco::.. ]</font>
<hr/>

<font face="Iceland" size="5" color="green" class="a">Africa AttaCker </font>

<p></p><font face="Iceland" size="5" color="Red" class="a">Group WH worms = Black Worm + Hierro Wins </font>

<p></p><font face="Iceland" size="3" color="red" class="a"> Morocco Hackers <3 </font>

<link href="http://fonts.googleapis.com/css?family=Iceland" rel="stylesheet" type="text/css">
<font face="Iceland" size="6" color="white" class="a">Thanx To 4lL
<center>

./By
in my public_html directory and as well my login parameter to WordPress admin dashboard was changed. When i entered through my database account, i found out my admin email has been changed to victoryosikwemhe@yahoo.com which i quickly updated back to mime.
So next day i saw the same index file changed to the same thing. i have carried out some of the security measures stated in Wordpress support site and wanna watch what will happen again but just wanna report this to the forum to take note of that. please copy and paste the below string to google search engine and see how many site has been hacked by the same group.
"Hacked by Zombie_L33T" OR "You got Hacked by Zombie_L33T|NIGERIAN CYBER ARMY"
This is their facebook address "https://www.facebook.com/naijacyberarmy".
If you know more about this please help.

nicklandry3 on "Site hack ?"

$
0
0

Hi !!

Im having a huge issue !
The other day, i went to my url and it showed my site was hacked. Ran securi and everything is ok. Added a firewall as well.

Did all my updates.

The problem im having is none of the content thats on my pages shows up on my site ?! Can anyone help ?

http://www.thenewoaktree.com


ericr23 on "Possible to enclose RSS feed posts in if statement?"

$
0
0

I have succeeded in moving all of my many customizations of Wordpress into a custom plugin except 1: I have an if condition in the RSS2 feed right inside "The Loop" to prevent unpublished posts to be displayed in the feed. (This is a workaround due to modifying the Search Everything plugin to include unpublished posts for logged in users, which then, however, allowed them to show up in a search term feed (.../?s=keyword&feed=rss2) for everyone. I think that was why it's there.)

I was wondering if there is any way, short of replacing the entire feed script, to filter in such an if enclosure. It would go right after "while(have_posts()): the_post();" and before "<item>" and end right before "endwhile;" and after "</item>".

Alternatively, can I replace the entire Loop (and only The Loop) in the rss feed via a plugin filter?

shahid07 on "This site may be fake"

$
0
0

I am using 4.1version but i have a problem.
When I open my college website on mobile it shows a message in red on top of website:
"This site may be fake"
But there is no similier website is on the internet.
My website url is:
http://gctkamalia.cu.cc/

asaracena on "site not found - images disappeared, pages put into trash"

$
0
0

This morning a client alerted me to their site showing a site not found message. No one had been in the admin panel since I last logged in several days ago (I only added a new user and changed my username from "admin"). I use WordFence so I know that no one else logged in.

When I took a closer look all the pages were in the trash. When I restored the pages none of the images were showing. When I looked in the FTP some of the images were there, most were not. I decided to restore the database as I hadn't done any work on the site since I backed it up 20 days ago.

After restoring the site I looked in the media library and the images were there, sort of. None were showing but they had the name, file sizes and upload date. I could see a couple if I pasted the url into a browser but not all.

I'm quite disturbed about this because it has happened before to one of my sites. Same thing - site not found, pages in trash, "ghost" images.

Any clue what might have happened?

thanks,
alison

jfaulkner on "HELP: Output location of plugin's echo"

$
0
0

Hey Friends, I'm writing a plugin for my employer which displays an output based on what is being displayed on the current page (like a custom ad sense kind of plugin).
The issue I am having is finding how to change where the echo prints out to. It is defaulting to inside <div id="text"> which restricts what I can do with it in terms of styling it. Can any of you point me to somewhere I can change the default echo output location?

Cheers

guy.joseph on "Reload shortcode on dropdown box changed"

$
0
0

Hi

I am writing a plugin which very simply loads data from a table in the database and displays it in a table on the frontend.

At the top of my table I have several dropdown boxes which are used to filter the data.

How do I go about reloading and updating the SQL query each time the dropdown boxes are changed?

I'm very new to developing in PHP so if any of my code is incorrect then please feel free to point it out to me.

Thanks

function renderswaplist() {

	$output = '<table>
	  <tr>
    <td><select name="baseSearch" id="baseSearch"><option value="" selected="selected">All</option></select></td>
    <td><select name="roleSearch" id="roleSearch"><option value="" selected="selected">All</option></select></td>
	<td><select name="dateSearch" id="dateSearch"><option value="" selected="selected">Any</option></select></td>
    <td><select name="lengthSearch" id="lengthSearch"><option value="" selected="selected">Any</option></select></td>
	<td><select name="timeSearch" id="timeSearch"><option value="" selected="selected">Any</option></select></td>
	<td></td>
	<td></td>
	<td></td>
  </tr>
  <tr>
  	<th>Base</th>
	<th>Role</th>
    	<th>Date</th>
    	<th>Days</th>
    	<th>Check In</th>
    	<th>Route</th>
    	<th>Staff Number</th>
    	<th>Comments</th>
  </tr>';

  global $wpdb;

  $tablename = $wpdb->prefix . "swaplist";

  foreach( $wpdb->get_results("SELECT * FROM $tablename;") as $key => $row) {
		$crewnumber = $row->crewnumber;
		$role = $row->role;
		$base = $row->base;
		$date = $row->startdate;
		$length = $row->length;
		$checkin  = $row->checkin;
		$route =  $row->route;
		$comments = $row->comments;
		$formatteddate = date( 'd M', strtotime($date));
		$formattedcheckin = date( 'H:i', strtotime($checkin));

		$output .= "<tr>
	<td>$base</td>
	<td>$role</td>
	<td>$formatteddate</td>
	<td>$length</td>
	<td>$formattedcheckin</td>
	<td>$route</td>
	<td>$crewnumber</td>
	<td>$comments</td>
  </tr>";

}

$output .= '</table>';

	return $output;
}

Wabsnasm on "Page slug same as term slug always redirects"

$
0
0

I have a page with the slug 'nursery' (/all-classes/nursery/), and also have a custom taxonomy term 'nursery' (/class-blog/nursery/).

When I use get_term_link, it gives me what I want: a link to /class-blog/nursery/.

But on clicking that link, I'm always redirected to /all-classes/nursery/.

That's probably because of the trailing 'nursery', but it's not correct and I wondered if anyone out there knows how to fix that. Flushing my permalink rules did not work.

Also, I need the page slug to be the same as the taxonomy term slug.

ryanbowden on "Having an add_action( 'user_new_form',) brakes another"

$
0
0

I am using the following action;

add_action( 'user_new_form', 'epx_add_user_form_to_admin_area',489);
function epx_add_user_form_to_admin_area($current){
   $current .= 'this is a test';
   echo $current;
}

The issue is the minute i put that in s2member which displays a load of options on the add user page in the admin not to display

http://prntscr.com/5qbvoq

^^That is when i have not got anything that whats s2 member shows

http://prntscr.com/5qbw32

^^That is when i use the code above.

It is like it is overwritten what s2member wants to display. What is the best way to output new themes without removing s2member items which are required!

Many Thanks for any help.


Bubblechaz on "Private Note box on User profiles."

$
0
0

Hi, Im trying to create a private notebox on user profiles page (Im also using Userpro plugin) I figured the way Id do this is to add a 'notes' row to the database, Then on the profile page, I have the shortcode for the userpro profile field.

Below that I have want a box which will show if admin has left any messages for that user, Users cant reply, and only the User whose profile its on can see the notes.

Im new to wordpress so please bare with. But Ive got it so that it will call the notes row for the user from the Database, However only admin can see the notes, how can I also make it so the user can see the notes too?

<?php

$user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator'; ?>
<?php if( array_intersect($allowed_roles, $user->roles ) ) {  ?>

  <?php global $current_user;
      get_currentuserinfo();

    ?>
	<h1><?php
	  echo 'notes: ' . $current_user->notes . "\n";
	  ?></h1>
<?php } ?>

So thats my code, Pretty simple (I just made a page template).

sufyan_hassan on "Is this code true or not ?!"

$
0
0

I am a beginner in coding but i have just wrote this code and i got an error :(

this code must be placed in author.php file , so it creates a follow button in author's page

and when i click on it , it should save the author-id in a logged-in user meta called "following" ..

<?php

if($_GET['follow']){fun1();}

function fun1()
{
$fauid = get_user_by( 'slug', get_query_var( 'author_name' ) );
$user_id= get_current_user_id();
$key = 'following';
$themeta = get_user_meta($user_id , $key, TRUE);
if($themeta != '') {
$user_id= get_current_user_id;
update_user_meta($user_id, 'following', $fauid); }

else {

$user_id= get_current_user_id;
add_user_meta($user_id , 'following' , $fauid , true );
update_user_meta($user_id, 'following', $fauid);
}
}

?>

<html>
<button id="Button" name="Button" onClick='location.href="?follow=1"'>Follow Me <3 <3</button>
</html>

but i think this meta have to be an "array variable" in order not to replace the previous author id

with the new one .

anyone can help me please ?

sohan5005 on "I want to make my own page builder"

$
0
0

Hi all,

I wanted to develop my own drag and drop page builder for my theme. But I have no idea where should I start.

I can do all visual things as a metabox. But have no idea how can I connect that data or shortcodes to the main content of the post. Even, I don't know if metabox is the right way to make a custom page builder.

So need help from you guys. Mainly I want to know 2 things here.

1. What is the right way to visualize my own page builder to the dashboard. Metabox or something else?

2. How can I make the default content editor collect data(shortcodes) from my editor as other page builders do.

Thanks in advance.
S.

mavenickster on "Category in URL instead of post type"

$
0
0

I was wonder if this is possible and how:

suppose I have a custom post type "Persons" with slug "person" and suppose "John Smith" is a person: I can access his page through the following URL:

http://www.example.com/person/john-smith/

Now, suppose I have the category "Actors" and suppose I apply it to the "person" John Smith; if I access the following URL:

http://www.example.com/actors/

John Smith will be listed in that page, but its URL will still be:

http://www.example.com/person/john-smith/

I was wondering if there is a way so that I can access John Smith's page also through the URL:

http://www.example.com/actors/john-smith/

That would be nice, because you can suppose that I have another category named "Directors" and, guess, John Smith is also a movie director and, guess again, I was wondering if there is also a way so that I can access John Smith's page even through the URL:

http://www.example.com/directors/john-smith/

In summary, I was wondering if there the possibility to access the same exact page through the following URLs:
http://www.example.com/person/john-smith/
http://www.example.com/actors/john-smith/
http://www.example.com/directors/john-smith/

obviously keeping the URL as it is, with no redirection.

What is happening now is that if I access

http://www.example.com/actors/john-smith/

I am redirected to

http://www.example.com/person/john-smith/

Thank you!

sescpapa on "random post metadata linking to specific page"

$
0
0

Ok.
Let' see if I can describe this.
I have the content of a random post that sort of welcomes you to the website I'm working on. And I have it followed by another parameter of that same post. It could be some metadata, though for now it's just the title.
What I want is to have that other parameter linking to a page where this random post will be permanently posted.
But the whole thing is a bit confusing because I haven't really understood how pages work. Are they subpages of my website that you can navigate to by clicking on buttons from my homepage? And can I really have them organized so that certain posts are posted on certain pages? And if so, can I get a post from a certain page and subsequently get some kind of metadata of that post linking to the page (not the post)?
Or is it so simple that I can just insert the desirable link in some metadata field when creating my post?

Viewing all 8245 articles
Browse latest View live




Latest Images