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

mostproplugindevever on "How to make simple plugin to edit all posts in bbPress?"

$
0
0

I want to code a plugin that adds certain text to all past and future bbPress posts including OPs.

This is my current code but it obviously doesn't do shit:

function cpr_test() { echo ('THIS WORKS!'); }
add_action ('cpr_test', 'bbp_update_reply')

How do I go about coding this kind of thing?

(I'm really new to this)


thetechnuttyuk on "Caching the latest ~5 posts with service worker"

$
0
0

Hey,

We have been playing around with Service Worker over the last week and have managed to implement it into WordPress so that it will cache things like the homepage and a few important pages for use offline, we have also made an offline page for everything else, something which we actually think WordPress should do by default, but anyway, my question is does anyone know a way to get Service Worker to cache the latest 5 or so posts?

Aside from adding them manually to the serviceworker.js, I am unsure how this could be implemented, so anyone who is also looking into this, or already knows would be of great help.

daveetasac on "Need to include custom fields in meta box select menu output"

$
0
0

Hello,

I've created a site to allow businesses to showcase their stores and associated coupons. In the front-end, they can select from a list of stores they've created, and can even see the address of each location in the dropdown as well. In the back-end, however, I can only view their name from the theme's custom post type meta box. This is a problem for me in case I need to update something, mainly because there might be multiple stores with the same name, and I have no to see which exact store is being referenced.

I'm using ACF Plugin for the custom fields.

Here's the code that works in the front end:

<select name="offer_store" id="offer_store" class="form-control" data-validation="conditional" data-conditional-field="offer_new_store" data-error="<?php esc_attr_e( 'Select the store this coupon is valid for', 'couponxl' ); ?>">
			        	<option value=""><?php _e( 'Select the store this coupon is valid for...', 'couponxl' ) ?></option>
				        <?php

						$stores = couponxl_get_custom_list( 'store', array(
							'author' => $current_user->ID,
							'orderby' => 'title',
				        	'order' => 'ASC',
							'posts_per_page' => '-1',
				        ) );

				        if( !empty( $stores ) ){
				        	foreach( $stores as $store_key => $store_name ){
								$address = get_field( "store_address_1", $store_key );
								$city = get_field( "store_city", $store_key );
								$state = get_field( "store_state", $store_key );
				        		echo '<option value="'.$store_key.'">'.$store_name.'&nbsp;&nbsp;( '.$address.',&nbsp&nbsp;'.$city.',&nbsp;&nbsp;'.$state.' )'.'</option>';
				        	}
				        }
				        ?>
			        </select>

I'm not sure how to insert the above code into the array below; I'm trying to show the address info next to the store name:

array(
			'id' => 'offer_store',
			'name' => __( 'Offer Store', 'couponxl' ),
			'type' => 'select',
			'options' => couponxl_get_custom_list( 'store', array(), 'title' ),
			'desc' => __( 'Select store of the offer.', 'couponxl' )
		),

Thanks in advance.

Martin Zunec on "Disable/remove password - login only with username"

$
0
0

Is this possible? I tried removing password in wp-login.php and some other files but no succes. I want all users to be able to login with their username only, without having to enter their password at all.

Hope someone can help me, thanks!

MakarkinPRO on "Change default registration/recovery password function"

$
0
0

Hello, I need change Email/Paswword to MobilePhoneNumber/SmsPassword registration and password recovery process.

Plan is:

1) Decline email field validation (to user may type they're phone number), the field email in WP Database will filled with numbers like: 14551156644 or 78545646512 or 33545654564
2) Create function to AutoGenerate 5-th number passwords like: 54565 or 44578 or 12546
3) The SMS will be going through the SMS-gateway (after sending user's status will be "Waiting".
4) It'll be waiting until the CORRECT 5-th number will be entered it'll be change status of user to "Customer".
4.1) FRAUD contorol if user requesting 3 or more times send him the SMS, it'll be locked and EMAIL will be sent to administrator with customer PASSWORD, where they'll call to him and activated it by the phone.
5) Probably it'll be plugin which will be installed and change WordPress user registration function.

Any ideas of how to make that happen?

TrishaM on "SQL query to delete metadata of a custom post type, not the post"

$
0
0

I posted this question on StackExchange but not getting answers, hoping someone here can help.....

I have a custom post type with a metakey/value associated for which I need to delete the metadata, but not the post itself.

This is further complicated by the fact that 2 other post types ('post' and 2 other CPTs) also have this same metakey/value pair, and I don't want to delete the metadata associated with those other post types, just one particular post type......so I can't just clean this metadata out of the wp_postmeta table without specifying which post type to isolate.

My SQL skills are not good enough yet to do this without a mistake (although I do have my DB backed up), I would be very grateful for any help.

Custom post type is 'deal'.
Metakey is 'resort_chain'.

Background if anyone is interested or would find it helpful: We setup a CPT with custom fields using ACF Pro, but found (after entering many hundreds of 'deals') that we were entering a lot of data that is better associated with the 'resort' and the 'deal' entry could be made much faster and more efficient by setting up another CPT ('resort') and associating a lot of the metadata with the Resort - that way many deals can be entered for each resort without repetitively entering resort information. That data is now associated to the Deal via a (ACF) 'relationship' field.

BUT I need to clean out the data that is still attached to the Deal(s) so that I can properly test the search/filter function as well as the template display.

I just want to be sure that I remove that data only from Deals posts and not from Resorts posts or our other custom post type ('faqs') - both of which do contain a lot of the same metadata.

HaloPinay on "Post Formats in Loop (loop in function w/sticky)"

$
0
0

In my index.php, I have

<?php
            if(have_posts()) :
                while(have_posts()) : the_post();
                    echo cool_post_article_normal_block();
                endwhile;
            endif;
?>

So in funcitons cool_post_article_normal_block() says...

link -> http://pastebin.com/WDDJC6ks

What I understand is that I'm supposed to modify between <article></article>but what I don't know how to do is get the post format conditionally; especially since there is already a sticky conditional-- and I don't know PHP well :(

I'm very new to PHP so I'm unsure how to do this. I have several post formats activated: quote, video, gallery, audio, image.

I'd like the loop to go something like:

if sticky
if quote
 show title only
if video, audio, gallery
 show title
 show excerpt
if image
 show title
 show featured image
else
if quote
 show title only
if video, audio, gallery
 show title
 show excerpt
if image
 show title
 show featured image

mellett on "xmlrpc_wp_insert_post_data help/examples"

$
0
0

What class/file should I install the function and add_filter() call in order to intercept the post request?

I've tried a number of areas, some don't get called at all, others don't have the data that I'm looking for (xmlrpc.php).

Does there also need to be a call to apply_filters(), before the function will be called? The problem I'm running into is that I don't think that the _insert_post() function of class-wp-xmlrpc-server.php is ever called which is the only place that I've found an apply_filters() call for 'xmlrpc_wp_insert_post_data'.

I'd appreciate any thoughts or suggestions because as it stands right now I'm just chasing my tail.

Thanks
Andy


Taro on "Search result based on menu category"

$
0
0

Hi All,

i'm looking for two pieces of code that can help me with the following:

I got posts and pages with a custom menu. These posts/pages got a custom template activated. The templates contains the menu for the specific posts and pages. This way i can order pages/posts in two different categories.

Now i like to change the search function; the search output should be based on the active custom menu category.

I named menu 1: Benelux and menu 2: International

1: First peace of code needs to be for the searchform.php
The code should look at the current active menu(category) and the search result should be based on the active menu.

If the menu is for example "Benelux" then the search result should only display pages/posts from the custom taxonomy that i made <input type="hidden" name="location" value="benelux" />
Or if the active menu is "International" then display pages/posts from the custom taxonomy <input type="hidden" name="location" value="international" />

I found the following code to get the menu category...not sure if this is useful..

(wp_nav_menu( array(
    'menu' => 'benelux'
) )

2: Second peace of code is needed for the search.php (header).
Because if the output should work correctly than we also need to change the menu for this search result page. Default the search.php uses the main menu.

So the following code needs to see if the pages/post contain taxonomy benelux or international and change the menu accordingly.

It would just be really awesome if this is possible.

Greatings,
Taro

amybryde on "Modify search results page to table - code for loop?"

$
0
0

The search results page looks horrible and I would like to modify to present a table since the search will mostly be used as a parts search. All inventory has been divided up into categories with 1 category being our Master Inventory list. Unfortunately, since the files are so large, I had to use the "Embed a document" plugin to create most of the pages of inventory.

After must research, I have found that I need to modify the look within the search.php file. My problem is that I am unsure what code to use to have it display correctly as a 6 column table (Part Number, NSN, Alt. P/N, description, condition and quantity) showing only the part number information searched. The data would have to be pulled from the data created from the "Embed a document" plugin. I am simply at a loss of how to create the needed loop to display this correctly so that just the part number search shows up instead of the whole long list of inventory.

As an example, try searching "50-8792-3"

The website is http://www.calportaviation.com.

Any help with the coding would be much appreciated!

Thank you!

bmontgomery on "How to sort the results of custom WP_Query by category name"

$
0
0

Hello,

I wrote a plugin that uses WP_Query to display some posts, depending of the users choices. The query is made on taxonomies.
It's working pretty well, but the only thing I'm not able to achieve is the order of the results.
I'd like to sort the results by catagory names, but it's not working...
In the args, here's what I wrote:

'orderby' => 'category',
'order' => 'asc',

I don't understand what's wrong. Could anybody help me?
Thanks

nicklas_bryntesson on "Automatically set page parent & page category to a page-template"

$
0
0

In an effort to super simplify a site for a client I'm trying to see if there is a elegant way to automatically set the page-category and page parent to specific page-templates.

Right now I'm having two specific page-template's named Instructors and Venues
On those pages i have a couple ACF fields to display some information.
Part of that information required me to register a function to set categories to pages.
The problem is that i know, that the people that is going to use the site in the end is going to find every possible way to confuse page-parent, category & page template.
So back to my question is there a not too overly complex way to automatically set a page's parent and category with the page template?

Im thinking in the line of regiester a function in functions.php that ask if_page_template is:
instructors -then set page category to "instructors" and page parent to, "instructors-top-page"

Been reading the codex and search the web for any similar solution or plugin but didn't manage to find anything yet, which leads me to think that it is either super simple, or away over my head.

Bat n Ball on "Number-only username?"

$
0
0

Hello,

Does anyone know if it is possible to restrict usernames to numbers only?

Also, is it possible to restrict the number length to, say, 10? No more and no less.

I am in the early stages of putting together a business case for a client who requires only numbers to be used as a username. This number is a unique identifier to their staff in their organisation, for example: 2398253635.

Any help and guidance very much appreciated.

Paul.

Cuti on "Query works in phpmyadmin but not with $wpdb"

$
0
0

Hello !

I am trying to retrieve all user meta (in columns) for each users (in rows).

I build (not without pain) this query that is working in phpmyadmin :

SET group_concat_max_len=16384;
SET @sql = NULL;
SELECT
  GROUP_CONCAT( DISTINCT
	CONCAT(
	  'MAX( IF ( M.meta_key = ''',
	  meta_key,
	  ''', M.meta_value, NULL)) AS `',
	  meta_key, '`'
	)
  ) INTO @sql
FROM wp_usermeta;

SET @sql =
CONCAT( ' SELECT *, ', @sql,
' FROM wp_users as U, wp_usermeta as M
WHERE U.id = M.user_id
GROUP BY U.id ' );

PREPARE stmt FROM @sql;
EXECUTE stmt;

But when I execute it with $wpdb->get_results, it returns an empty array.

Anyone can help ?

amhinson on "Ideas to create custom member content automatically"

$
0
0

I run a percussion instruction membership website. For each student, I give them a personalized "practice sheet" on the website that is updated automatically based on what exercise/tempo they mark as complete. Currently, here is how I am achieving this:

- I have a master Google Sheets document that contains all of the exercises and formulas that create the "practice sheet" on a different sheet, and there is also a Google Form attached to it for submission.
- When a member signs up through Paid Membership Pro, I have the "User Pages" add-on to create a page just for that user with some generic content.
- I then go in and create a new Google Sheet/Form from the master and then embed their unique form and practice sheet onto their user page so that they can submit the exercise/tempo and it will automatically show on the practice sheet on the same page once it is submitted.

Obviously this is not a sustainable practice if I want the website to grow.
I'm just looking for some general ideas of how I could use the database in Wordpress instead of Google Sheets, and also how I could create just one page that all members would go to and it would only show their information. Any thoughts would be greatly appreciated!


joe34 on "BBPress Notifications based on ForumId and Member Role"

$
0
0

Hey I am using BBPress, BBPress Notifications (No Spam), and User Role Editor.
I want to make it so that when a new topic is posted in a certain forum, only certain members get a notification based on where it was posted.

I have tried to hack this together but have been unable to get conclusive results, so any tips or help will be much appreciated.

stevenatsalt on "functions.php code to turn off image cropping"

$
0
0

Hi all,

I've had a root around but I cannot find what I'm looking for, hopefully someone here can help me out.

I'm trying to find a snippet of code that will automatically turn off cropping images on the thumbnail size.

on https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size I saw an example: set_post_thumbnail_size( 50, 50, true ); // 50 pixels wide by 50 pixels tall, crop mode
So I tried to say False to hopefully turn it off, but then realised that didn't work.

I already set the sizes in my functions.php file with:

update_option('thumbnail_size_w', 300);
update_option('thumbnail_size_h', 99999);
update_option('medium_size_w', 600);
update_option('medium_size_h', 99999);
update_option('large_size_w', 1200);
update_option('large_size_h', 99999);

Any ideas?

Thanks.

leoncc84 on "#ICQ:84488484 SELL CVV ( LIVE 100% ) GOOD AND FRESH ALL COUNTRY"

$
0
0

SELL CVV CC CCV, FULLZ, DUMP TRACK 1/2, GIFT CARD GOOD QUALITY, FRESH, REPLACE IF BAD
*---ICQ:84488484

*------Gmail:leonsellcvv84@gmail.com

*-----------------Yahoo!:leonseller84
----------------------------------------­----------------------------------------­----------------------

You need a CVV and more. We need a good buyer for business long time. Why don't you contact us?
1/ Sell CVV normal, fullz info cvv of those countries : UK, US, EU, CA, AUS and some other countries
2/ Sell Dump, T1/T2 good balance of those countries : UK, US, EU, CA, AUS and some other countries
3/ Sell Mail Pass, RPD, personal information
4/ and some other sutff.
...
Contact us to know exactly price. Best price for a bulk order
----------------------------------------­----------------------------------------­----------------------
Reading below carefully before contact us:
We have to resolve many orders at a time, so you should save your time and your breath: no play game, no joking,
no asking a free test, sample, proof like thousands guys ask us everyday. If u need a test, I recommend
u should buy 1 first to test.

Leave ur message in my contact I ll connect to you ASAP.
----------------------------------------­----------------------------------------­----------------------

PAYMENT: BTC, WMZ, PM, Western Union

I hope to have a long-term business with you

Thanks for your reading

ionurboz on "Wordpress re-send register details and password!"

$
0
0

Hi,

I work a project..

I do make custom register / login / reset password page without wp-login.php

I want to create new page (re-send password to e-mail):

One way, I am get user email within one form. And get user data by email. After deleted user, insert new user from old data.

Problem: User posts, settings more details lost!

The solutions: I am check the user have post or change more detail, return to user wrong this account already used by you!

Main question:

I am want to check user login any time?

I think add a user meta user_lastlogin,'null' and update user meta from wp-login hook. user_lastlogin, time()

It will be give me a problem?

KennyLL on "WP 4.4 Responsive Images (srcset/sizes) in Text Widget?!?"

$
0
0

I'm slowly wrapping my head around the new responsive images features in WP 4.4. I've got it fairly well figured out now for our CPTs & default page/post content images.

- But is there a way to have the new WP srcset & sizes attributes added to an image placed in a standard Text widget??

We could hard-code all of the extra data in the widget, but that would just be unwieldy to deal with and/or make updates to (there will be quite a few of them). Hoping there is a function or something that could replace a standard <img src="full-size-original.jpg"> with all of the srcset & sizes attributes as happens with images placed in content editor.

And ideally it might be nice to know how to modify the sizes attribute if needed. We were able to find something for post thumbnails, but not sure it would work here.

THANKS!

Viewing all 8245 articles
Browse latest View live




Latest Images